1

I have created an application in the IBM Watson IoT Platform, and I used the code sample provided to connect an ApplicationClient object.

The connection is fine, but when the publish command is sent, after a second or two I got this in the output window of VS2017:

Exception levée : 'System.Net.Sockets.SocketException' dans System.dll
Exception levée : 'System.IO.IOException' dans System.dll
Exception levée : 'System.IO.IOException' dans System.dll
Le thread 0x4a4 s'est arrêté avec le code 0 (0x0).
Exception levée : 'System.Security.Cryptography.CryptographicException' 
dans mscorlib.dll

the thing is, I have used try/catch block everywhere, but they don't catch those exceptions.

I can guess it's about ports forwarding but even after opening the ports required by watson iot, I can't seem to have the command working

I can successfully publish events from device and reception those events on an ApplicationClient, I only have problems with Command.

EDIT: add clarification

  • I don't know which port exactly is used, its the IBMWIoTP who manage the connection, but the docs says to open 1883, 80, 8883 and 443. Which I did, both in the windows firewall and my router.

  • The publish method looks like this:

    appClient.publishCommand("Raspberry", "Pi2B", "pi", "txt", data, 0); where Raspberry is the device type; Pi2B the device id, pi the topic, txt the format, data is a string and 0 is the QoS.

  • I'm using the recommended Nuget library by IBM : IBMWIoTP

  • I tried to set TLS optional in security but this doesn't solve the issue

  • I found the exact moment I have the uncaught exception, in the IBMWIoTP library source code, on the connect method:

connevtionState = mqttClient.Connect(clientId, clientUsername, clientPassword,cleanSession,keepAlivePeriod);
Jason Aller
  • 3,541
  • 28
  • 38
  • 38
Mackhdo
  • 110
  • 8
  • over what port do you connect? It looks like over secure connection so I guess it is over 8883. What libraries are you using? How does the publish method looks like? – idan Mar 31 '19 at 17:27
  • I edited my original question to answer. – Mackhdo Mar 31 '19 at 18:18

2 Answers2

0

Dropped connections can indicate you're trying to do something illegal, such as publishing to a topic you're not allowed to.

Ben Bakowski
  • 103
  • 5
0

Ok, i found why...and i'm ashamed. I have affected the wrong profile on the application, i couldn't send command with this profile. I have set a standard application profile and now everything works fine. I wasted too many hours on this...

Mackhdo
  • 110
  • 8