Chat freely about anything...

User avatar
By popcorn
#1142 I set a new goal. I'm trying to connect a App or Html page with the Esp8266, and making a socket connection..

I'm able to connect to the Esp using a program on the computer:
http://sockettest.sourceforge.net/

Then I tried a Cordova (Android / Ios) plugin to try to setup a socket connection. I tried:
https://github.com/Tlantic/cdv-socket-plugin

But I'm unable to connect :(..

____________________________

I want to configure my esp8266 as server so I setup like this in the Serial console:

*** SERIAL ***
// Connect to the network
AT+CWJAP="SSID","PASS"
AT+CIFSR
192.168.1.103

// Make it a server
AT+CIPMUX=1
AT+CIPSERVER=1,8000
*** /SERIAL

*** HTML ***
Then I have a HTML page trying to connect to the server:
if ("WebSocket" in window) {
console.log("WebSocket is supported by your Browser!");
// open the websocket
ws = new WebSocket("ws://192.168.1.103:8000");
}
*** /HTML ***

When the HTML page visit the server I get:

*** SERIAL ***
+IPD,0,431:GET / HTTP/1.1
Upgrade: websocket
Connection: Upgrade
Host: 192.168.1.103:8000
Origin: null
Pragma: no-cache
Cache-Control: no-cache
Sec-WebSocket-Key: dCJ7dO0cFCL8Bfjszc6CVg==
Sec-WebSocket-Version: 13
Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits, x-webkit-deflate-frame
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 Safari/537.36


OK
*** /SERIAL ***

After a while my webconsole displays:
*** HTML ***
WebSocket connection to 'ws://192.168.1.103:8000/' failed: Connection closed before receiving a handshake response
** /HTML ***

And ESP said...
*** SERIAL ***
Unlink
*** /SERIAL ***

I tried to send messages in both way. But I think there must be a handshake first.
Last edited by popcorn on Mon Oct 06, 2014 7:15 am, edited 2 times in total.
User avatar
By villTech
#1149
popcorn wrote:After a while my webconsole displays:
*** HTML ***
WebSocket connection to 'ws://192.168.1.103:8000/' failed: Connection closed before receiving a handshake response
** /HTML ***

And ESP said...
*** SERIAL ***
Unlink
*** /SERIAL ***

I tried to send messages in both way. But I think there must be a handshake first.

after getting connected, there will be a connection timeout when no data is being tx'd/rx'd.
connection will automatically be terminated by esp module. you will need to reconnect.
User avatar
By popcorn
#1156 Yeah after a while its disconnected.

But in that time it must be possible in some way to send data right? My console said its missing handshake before it can send data :cry:
User avatar
By wififofum
#1157 http://en.m.wikipedia.org/wiki/WebSocket

You have to send the server response to the browser. In addition, you would have to implement the other features of a websocket server. So basically you probably don't want to use websockets.
Last edited by wififofum on Fri Oct 03, 2014 2:54 pm, edited 1 time in total.