lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-users] LWIP and Websockets


From: Leonardo Martínez
Subject: [lwip-users] LWIP and Websockets
Date: Fri, 23 Oct 2015 21:21:47 -0300

Hi All,

I am working with the Atmel Xplained Ultra Board and its LWIP sample code. I would like to be able to exchange messages with a HTML5 app using WebSockets. 

My idea is to modify the sample code to answer to the handshake and then, without closing the TCP connection, exchange websockets messages directly there, within the already established connection.

Well, I have obtained the handshake request and correctly made the response (using SHA-1 and base64 as in https://developer.mozilla.org/en-US/...Socket_servers).
But, no tcp message is being sent to the browser by my board as a handshake response. I don't know why because the code is exactly as it works while serving a webpage. 

I am also using Hercules to test this and I can see that if I ask for the website, I get it, but if I send a websocket handshake, the response does not show up.

What can it be? Is it something wrong with my reasoning?


The code looks like this:

....
requestType = decodeHttpMessage (data, &outputMessage[0], &messageLength);
if(requestType)
{
//WebSocket Message
pmessage = &outputMessage[0];
hs->file = pmessage;
hs->left = 129;

pbuf_free(p);
http_send_data(pcb, hs);
/* Tell TCP that we wish be to informed of data that has been
successfully sent by a call to the http_sent() function. */
tcp_sent(pcb, http_sent);
}
else
        {      //The provided implementation for serving HTML. Here, it works   }
...

Comments after testing:
- I get ERR_CONNECTION_RESET in Chrome at websocket = new WebSocket("ws://192.168.0.122");
- I am getting ERR_OK from the call to tcp_write(....)
- http_poll is called 4 times and finally it calls TCP_ABORT.
- After entering to the websocket part of the IF statement once, no more connections are accepted. That doesn't happen if I just ask for the webpage and reload it many times.

Thanks in advance!

--
Leonardo Martinez.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]