Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Paho » MQTT javascript websockets ssl client within android web browser
MQTT javascript websockets ssl client within android web browser [message #1726964] Thu, 17 March 2016 18:28 Go to next message
Costas Makris is currently offline Costas MakrisFriend
Messages: 3
Registered: March 2016
Junior Member
Hello everyone,

I have created a web page using the paho javascript MQTT client. The client uses websockets with SSL. It works perfectly well on my windows PC connecting to a Mosquitto server and exchanging messages. When I try the same web page from an android phone (chrome browser) it fails to connect to the server.

I am a bit lost on this one and any help will be appriciated. The server log file gives this error:

1458238560: insert_wsi_socket_into_fds: wsi=0x14e0b58, sock=10, fds pos=2
1458238560: inserted SSL accept into fds, trying SSL_accept
1458238560: SSL_accept failed 2 / error:00000002:lib(0):func(0):system lib
1458238560: SSL_ERROR_WANT_READ
1458238560: accepted new SSL conn
1458238560: lws_server_skt_srv: read 0 len
1458238560: close: just_kill_connection
1458238560: remove_wsi_socket_from_fds: wsi=0x14e0b58, sock=10, fds pos=2
1458238560: not calling back closed
Re: MQTT javascript websockets ssl client within android web browser [message #1727009 is a reply to message #1726964] Fri, 18 March 2016 09:09 Go to previous messageGo to next message
James Sutton is currently offline James SuttonFriend
Messages: 69
Registered: July 2015
Member
Hi,
From the mosquitto logs, it looks like something is going wrong when the client is trying to connect using TLS (SSL), It might be worth looking at the web console logs to see what error comes back from the Javascript client, a good way to live debug is described here: https://developer.chrome.com/devtools/docs/remote-debugging

Another thing that might be worth trying would be to see whether your web application can connect to the iot.eclipse.org mosquitto server, this might help you figure out if it's an issue with the client or the server. Instructions are here: http://iot.eclipse.org/getting-started#sandboxes but all you really need to do is to use this uri: wss://iot.eclipse.org:443/ws

If you don't have any luck, post the console log output from the Javascript client and we might be able to figure it out Smile
Re: MQTT javascript websockets ssl client within android web browser [message #1727085 is a reply to message #1727009] Fri, 18 March 2016 17:52 Go to previous messageGo to next message
Costas Makris is currently offline Costas MakrisFriend
Messages: 3
Registered: March 2016
Junior Member
Hi again,

I followed your advice and installed the chrome dev tools. Found out that the problem was the self signed ssl certificate. By accepting the certificate during a normal https request directrly to the mosquitto server addr:wss-port from the mobile chrome browser the problem disappeared! I am not sure if this would be a permanent solution.
Is there any other way to deal with self signed certificates for use with the Paho js mqtt client on Android phones?

Thanks again.
Re: MQTT javascript websockets ssl client within android web browser [message #1727195 is a reply to message #1727085] Mon, 21 March 2016 08:36 Go to previous messageGo to next message
James Sutton is currently offline James SuttonFriend
Messages: 69
Registered: July 2015
Member
HTTPS certificate management is done at the browser level and the javascript running in the web page (i.e. the paho client) has no access or visibility to the certificates themselves. Your options would be to either manually install the certificate into the chrome browser on every device, or get an officially signed certificate that would be valid on any web browser. There are a number of companies that now provide free TLS certificates for anyone which may be a good option for you:

https://letsencrypt.org/

https://www.startssl.com/Support?v=39
Re: MQTT javascript websockets ssl client within android web browser [message #1727645 is a reply to message #1727195] Thu, 24 March 2016 17:27 Go to previous message
Costas Makris is currently offline Costas MakrisFriend
Messages: 3
Registered: March 2016
Junior Member
Ok. Thank you James for the help and advice.
Previous Topic:The listener of publish method does not work asynchronously on Mqtt in Eclipse Paho Project
Next Topic:Paho MQTT C Client was hung-up while connecting to an non-existing Broker
Goto Forum:
  


Current Time: Sat Sep 22 05:36:26 GMT 2018

Powered by FUDForum. Page generated in 0.01921 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top