EHS5: WebSocket: link to the server | Telit Cinterion IoT Developer Community
June 25, 2019 - 12:29pm, 2406 views
Hello all,
I have to implement OCPP1.6-JSON with websockets on EHS. I have a j2me websocket library.
I can not create a connection to the server because of the link.
When running on pc, the link is:
ws://mydomain.co:myport/steve/websocket/CentralSystemService/RO*LEK*E000001
When running on EHS, the link can not start with ws.
If I use:
socket://mydomain.co:myport/steve/websocket/CentralSystemService/RO*LEK*E000001
I receive: java.lang.IllegalArgumentException : Malformed address.
If I use:
socket://mydomain.co:myport
a connection is created, no exception is thrown, but the connection is not to the server.
What should be the correct link to my server ?
Thank you for your time.
Best Regards,
Mihaela
Hello,
The module's API does not support 'ws:' URI. So if you have a third party websocket API it must be using the module's API in the end to make a connection so there must be 'socket:' used in the end.
Did you have to adopt this web socket API to work on the module?
Can you paste the complete stack trace to show from where the exception was thrown?
Best regards,
Bartłomiej
Hello,
"Did you have to adopt this web socket API to work on the module?"
This is the j2me library that I found: https://www.javatips.net/api/jwebsocket-master/jWebSocket/jwebSocketJavaMEClient/src/org/jwebsocket/client/me/BaseClientJ2ME.java
I don't think that I changed anything, or I made only minor changes.
"Can you paste the complete stack trace to show from where the exception was thrown? "
the code:
where url=socket://mydomain.co:myport/steve/websocket/CentralSystemService/RO*LEK*E000001
the stack trace:
Best Regards,
Mihaela
Hello,
So it is thrown from com.sun.midp.io.j2me.socket.*.
I suppose that the reason could be that you open socket: with an 'http style' address string while socket just expects a domain and port. If the WebSocket lib passes the full string you pass to Connector.open() it is probably treated as malformed address.
I'm not an expert on web sockets but maybe in this case 'http' would work better instead of 'socket'.
Regards,
Bartłomiej