1

I am beginning to use the sample IBM-IOT C# sample code as per https://github.com/ibm-watson-iot/iot-csharp/blob/master/docs/Gateway.rst

however I get "An invalid IP address was specified." thrown when the gateway constructor is called using the org id.

I'm using an orgid of 'p3wg4w' (set in config and accessed as a string property Globals.WatsonOrgID" ) my code is

    private static void InitGatewayClient()
    {
        if (gw == null)
        {
            gw = new GatewayClient(Globals.WatsonOrgID,
                Globals.WatsonGatewayDeviceType,
                Globals.WatsonGatewayDeviceID,
                Globals.WatsonAuthMethod,
                Globals.WatsonToken);
            gw.commandCallback += processCommand;
            gw.errorCallback += processError;
            gw.connect();
            Console.WriteLine("Gateway connected");
            Console.WriteLine("publishing gateway events..");
        }
    }

Has anyone seen this before ?

Zaphod
  • 11
  • 3

1 Answers1

1

check if you can access or if you can: telnet p3wg4w.messaging.internetofthings.ibmcloud.com 8883

The libraries aren't using any IP to create the connection, it is using the below vars

public static string DOMAIN = ".messaging.internetofthings.ibmcloud.com"; public static int MQTTS_PORT = 8883;

I can only think that your firewall is blocking the connection

I've used the below sample and worked just fine for me:

https://github.com/ibm-watson-iot/iot-csharp/blob/master/sample/Gateway/SampleGateway.cs

idan
  • 554
  • 6
  • 19
  • thanks for the sugestion, I also built and ran the sample as a separate project. it works fine from our site. I'm actually trying to integrate this into an existing product , and I think there are some incompatibilities with runtime versions of some client libraries which are causing name resolution to fail. – Zaphod Oct 17 '17 at 13:35
  • if that gives you problem, then I guess you can give a try and use mqtt paho client https://www.eclipse.org/paho/clients/dotnet/ you can then just configure the mqtt client object to connect to the IBM Watson IoT Platform – idan Oct 17 '17 at 13:59