8 years, 10 months ago.

mbed Websocket connection issues

I have created a websocket server using java with netbeans IDE. My client is mbed K64F, which sends/receive the data to/from the java websocket server. Every thing is working fine so far, but I have few issues here 1) Mbed take 45 seconds to connect to websocket server: I dont know what is the main reason but my mbed client takes approx one min to connect to server, i think it looks like the handshake protocol is a bit different between mbed and java, can any one suggest some possible solution to reduce this time.

2) After every 2-3 hours the connection between server and client vanish: I couldnt figure out the possible reason but i tried to write a code to deal with this problem, that if connection goes down mbed should restart it self following is my logic

#include "mbed.h"
extern "C" void mbed_reset();
int main()
{
Websocket ws(ws://ip/myserver);
ws.connect();
printf("connected \n");
int count=0;
while (1)
{
if (ws.is_connected)
{
count++;
if (Interrupt)
ws.send("interrupt generated");
}
if (ws.read())
count--;

if (count>3)
NVIC_SystemReset();

}
}

Surprisingly (ws.is_connected) returns true after the connection drop as well, but it stopped to receive message from the server side so I made the logic as if it has not received any reply from server for more than 3 times it will restart it self.

just a minor tweek, it was not a websocket connection issue, it was a server issue, if the computer(websocket server) is in standby mode it will drop the connections. so we need to avoid the computer to go to standby mode

posted by zain aftab 23 Jun 2015
Be the first to answer this question.