10 years, 1 month ago.  This question has been closed. Reason: Too broad - no single answer

Connecting mbed device to server?

I've made my own server using node.js and socket.io. I can connect web pages but cannot connect the mbed device using a websocket class. I'm trying to connect over two different classes (WebSocketClient or SocketIO) and trying to connect via www.srelog.com:49152 or 192.168.0.100:49152. Here's my code:

SocketIO socketio("192.168.0.100:49152");
//SocketIO socketio("srelog.com:49152");
//Websocket ws("192.168.0.100:49152");
Websocket ws("srelog.com:49152");

int main() 
{
    pc.printf("\n\r***** WEBSOCKET DEMO *****\n\r");
    lcd.locate(0, 0);
    lcd.printf("WebsocketDemo");
    
    //set up wifi with failure protocall
    wifi.init();
    if (wifi.connect() == -1) 
    {
        lcd.locate(0, 1);
        lcd.printf("No Internet 1");
        wait(1);
    } 
    else
    {
        lcd.locate(0, 1);
        lcd.printf("IP: %s", wifi.getIPAddress());
        wait(1);
    }
    
    if(ws.connect() == true)
    {
        pc.printf("WSS connected to %s\n\r", ws);
    }
    else
    {
        pc.printf("Not connected.ws\n\r");   
    }
    
    if(socketio.connect() == true)
    {
        pc.printf("connected with socket.io\n\r");   
    }
    else
    {
        pc.printf("Not connected.io\n\r");   
    }
}

I set up the wifi and includes etc successfully, the error is connecting to my server address. Thanks for any help.

Question relating to:

Have you tried connecting to http://sockets.mbed.org/ with some of the example programs http://developer.mbed.org/cookbook/Websocket-and-Mbed

Some of the Wifly modules (guessing that's what you're using) ship with quite old firmware and should be updated.

It would also be beneficial to publish a program so others can see the code as you left it rather than guessing what libraries and version you've used.

posted by Sam Grove 08 Oct 2014