Oct 23, 2014 Replies: 7 This library allows you to create secure (wss://) and non-secure (ws://) WebSocket connections. It is based on https://github.com/palmerc/SecureWebSockets, which adds SSL support to the Autobahn WebSocket library. Usage is exactly same as WebSocket library: http://www.b4x.com/android/forum/threads/websocket-client-library.40221/ Thanks to @Erel for his help! NOTE: There are some limitations w.r.to connecting to LAN addresses / non-default ports. Attachments SecureWebSocket-1.0.zip SecureWebSocket-1.0.zip 42.5 KB · Views: 833 Last edited: Oct 24, 2014 Click to expand...
This library allows you to create secure (wss://) and non-secure (ws://) WebSocket connections. It is based on https://github.com/palmerc/SecureWebSockets, which adds SSL support to the Autobahn WebSocket library. Usage is exactly same as WebSocket library: http://www.b4x.com/android/forum/threads/websocket-client-library.40221/ Thanks to @Erel for his help! NOTE: There are some limitations w.r.to connecting to LAN addresses / non-default ports.
woniol Active Member Licensed User Longtime User Oct 24, 2014 #2 Do I need to change something in server config? I just replaced WebSocket with SecureWebsocket Class in my project and I get: Conneting to WS server at: wss://xx.xx.xxx.xxx:8888/ws WSHEnandler: WebSockets internal error (java.lang.NullPointerException) Disconnected from WS server: WebSockets internal error (java.lang.NullPointerException) the: WebSockets internal error (java.lang.NullPointerException) comes form ws_Closed event
Do I need to change something in server config? I just replaced WebSocket with SecureWebsocket Class in my project and I get: Conneting to WS server at: wss://xx.xx.xxx.xxx:8888/ws WSHEnandler: WebSockets internal error (java.lang.NullPointerException) Disconnected from WS server: WebSockets internal error (java.lang.NullPointerException) the: WebSockets internal error (java.lang.NullPointerException) comes form ws_Closed event
woniol Active Member Licensed User Longtime User Oct 24, 2014 #3 The same results with Erel's examples from : http://www.b4x.com/android/forum/threads/websocket-client-library.40221/#content
The same results with Erel's examples from : http://www.b4x.com/android/forum/threads/websocket-client-library.40221/#content
D daemon Active Member Licensed User Longtime User Oct 24, 2014 #4 I too have faced this issue. It seems this code supports wss:// connections only to default port (443). I have tested it working with wss://echo.websocket.org.
I too have faced this issue. It seems this code supports wss:// connections only to default port (443). I have tested it working with wss://echo.websocket.org.
woniol Active Member Licensed User Longtime User Oct 24, 2014 #5 Works fine with wss://echo.websocket.org Looks like it needs some config on server side.
D daemon Active Member Licensed User Longtime User Oct 24, 2014 #6 May be. It works on heroku as well, without any specific configuration.
Erel B4X founder Staff member Licensed User Longtime User Oct 26, 2014 #7 @daemon you should print the full error message in your library. This way you will be able to understand which code fails.
@daemon you should print the full error message in your library. This way you will be able to understand which code fails.
D daemon Active Member Licensed User Longtime User Oct 26, 2014 #8 Tried debugging a little bit, found that the WebSocket library uses SSLCertificateSocketFactory to create a socket, which seems to return a closed socket for such conditions: https://github.com/palmerc/SecureWe...avendo/autobahn/WebSocketConnection.java#L484 This results in NullPointerException at: https://github.com/palmerc/SecureWe...de/tavendo/autobahn/WebSocketWriter.java#L382 And the WebSocket library calls onClose() on any exception with Reason set to details.
Tried debugging a little bit, found that the WebSocket library uses SSLCertificateSocketFactory to create a socket, which seems to return a closed socket for such conditions: https://github.com/palmerc/SecureWe...avendo/autobahn/WebSocketConnection.java#L484 This results in NullPointerException at: https://github.com/palmerc/SecureWe...de/tavendo/autobahn/WebSocketWriter.java#L382 And the WebSocket library calls onClose() on any exception with Reason set to details.