Hello,
at first i would like to say, im just started with ESP8266. I tried simple program form github:
https://github.com/morrissinger/ESP8266-Websocket/blob/master/examples/WebSocketClient_Demo/WebSocketClient_Demo.ino
When i am connecting with echo.websocket.org its working fine, i can send and read data from server. But i cant connect with server whose adress is: wss://example/device. Does anyone know the solution of this problem?
Thanks for help
Sorry for my english
Is the host "example" alive and dns resolvable on your network ?
Try replacing WiFiClient client; by WiFiClientSecure client;.
Hi, thanks for help but i cant complie this Example.

you need the staring or git version of the ESP core
Thanks, its compiling now. But i still can't connect. In method webSocket.beginSSL should i write webSocket.beginSSL("wss://adress/device") or just webSocket.beginSSL("adress/device")? Defualt port is 443?
Do u know any test SSL server with can i test this program?
When i am trying to connect echo.websocket.org i get an exception: please start sntp first !
This isn't an exception, just a debug message from the SDK. You can safely
ignore it.
If you are really getting an exception, it is likely unrelated to this
message.
On Sat, Jan 16, 2016, 22:27 qblacksheep [email protected] wrote:
When i am trying to connect echo.websocket.org i get an exception: please
start sntp first !—
Reply to this email directly or view it on GitHub
https://github.com/esp8266/Arduino/issues/1442#issuecomment-172248270.
Ok. But i still can't connect to any wss:// server. I was trying to connect to echo.websocket.org.

. In method webSocket.beginSSL should i write webSocket.beginSSL("wss://echo.websocket.org") or just webSocket.beginSSL("echo.websocket.org")?
webSocket.beginSSL("echo.websocket.org", 443);
Now im getting this:

see: #1375
the Certificate size / key length is too big
Do you know any test SSL server with path where i can test websockets? i can't connect with my server maybe couse i have wss://webrouter.server/path. What do you think?
webSocket.beginSSL("webrouter.server", 443, "/path");
Thanks for help guys. But unfortunately i still can't connect to server. Has that debug message:: "please start sntp first !" have impact to conneting the server?

normally not.
add configTime(3 * 3600, 0, "pool.ntp.org", "time.nist.gov"); to the setup and it will be gone.
try to enable debug to see the reason for the disconnect.
https://github.com/Links2004/arduinoWebSockets/blob/master/src/WebSockets.h#L30

Is that client or server failure?
the server returns 503 header so its a server problem, check the server logs.
Thanks a lot! :)
Did someone try to send and get ws from server on herokuapp.com? I can easily send and recive data on server which standing on local web but when i trying to connect to this same server standing on herokuapp.com its returns 503.
from server which i CAN connect i recive header connection:upgrade, from server which i CAN'T connect i recive header connection:keep-alive. How to change it? maybe there is a problem.
the server not accepts the WebSocket connection,
connection:upgrade is required for ws.
do your webserver really supports ws?
what software do you use as server?
I use Netty deployed on Heroku. Server logs are:
Exception caught in Netty
org.jboss.netty.handler.codec.http.websocketx.WebSocketHandshakeException: Requested subprotocol(s) not supported: arduino
When I run server locally on Tomcat, it works fine
Requested subprotocol(s) not supported: arduino
is a good hint.
the client sends:
Sec-WebSocket-Protocol: arduino
the Server seams to not accept this.
you can try to remove this line:
https://github.com/Links2004/arduinoWebSockets/blob/master/src/WebSocketsClient.cpp#L369
if its working i can a option to disable/override it, then you can add something your server allows.
Its working now. Thanks a lot!!
It would be nice to have option to not include this header. Look at netty implementation http://netty.io/3.6/xref/org/jboss/netty/handler/codec/http/websocketx/WebSocketServerHandshaker13.html
line 160-169. It throws exception only if there is unrecognized "Sec-WebSocket-Protocol" value. If there is no such header, netty uses default protocol and continues execution.
Hello All,
I am facing issues with web-sockets.My node MCU works as a web-socket client.It connects fine and able to do a bi-directional communication but after some time my client is dead silently without notification.
webSocket.beginSSL("YYYYYYYYYYYYYYYYYYYYYYYYY", 443, "/UUUUUUUUUUUUU");
webSocket.setAuthorization("CCCCCCCCCCCCCCCCCC");
webSocket.onEvent(webSocketEvent);
in the loop()
{
I was listening for the websocket event in the loop
}
even though it fails silently without notification. I am in the last phase of the project with a big issue.Please throw some light.
hey there, I'm having exactly the same issue. I seem to be unable of removing the line of code that its emitting the Arduino protocol. Here is what I'm getting:
[WS-Client][sendHeader] sending header...
[WS-Client][sendHeader] handshake GET /chat HTTP/1.1
Connection: Upgrade
Upgrade: websocket
Sec-WebSocket-Version: 13
Sec-WebSocket-Key: lJhypUjVIuYxris9IlVfjw==
Sec-WebSocket-Protocol: arduino
Origin: file://
User-Agent: arduino-WebSocket-Client
[write] n: 249 t: 125964
[WS-Client][sendHeader] sending header... Done (24231us).
[WS-Client][handleHeader] RX: HTTP/1.1 502 Bad Gateway
[WS-Client][handleHeader] RX: Server: nginx/1.10.3 (Ubuntu)
[WS-Client][handleHeader] RX: Date: Fri, 29 Mar 2019 06:19:52 GMT
[WS-Client][handleHeader] RX: Content-Type: text/html
[WS-Client][handleHeader] RX: Content-Length: 182
[WS-Client][handleHeader] RX: Connection: keep-alive
[WS-Client][handleHeader] Header read fin.
[WS-Client][handleHeader] Client settings:
[WS-Client][handleHeader] - cURL: /chat
[WS-Client][handleHeader] - cKey: lJhypUjVIuYxris9IlVfjw==
[WS-Client][handleHeader] Server header:
[WS-Client][handleHeader] - cCode: 502
[WS-Client][handleHeader] - cIsUpgrade: 0
[WS-Client][handleHeader] - cIsWebsocket: 0
[WS-Client][handleHeader] - cAccept:
[WS-Client][handleHeader] - cProtocol: arduino
[WS-Client][handleHeader] - cExtensions:
[WS-Client][handleHeader] - cVersion: 0
[WS-Client][handleHeader] - cSessionId:
[WS-Client][handleHeader] no Websocket connection close.
[write] n: 27 t: 127137
[WS-Client] client disconnected.
[WSc] Disconnected!
here are the logs for the nginx whicih is running as a reverse proxy server:
[29/Mar/2019:06:15:47 +0000] "GET /chat HTTP/1.1" 502 182 "-" "arduino-WebSocket-Client"
[29/Mar/2019:06:15:47 +0000] "This is a webSocket client!" 400 182 "-" "-"
and the error.log file:
upstream prematurely closed connection while reading response header from upstream, request: "GET /chat HTTP/1.1"
my theory so far is that the upstream nodejs server is returning a 502 bad request due to the Sec-WebSocket-Protocol: arduino sent. I would appreciate if you could give me some advice.
Its working now. Thanks a lot!!
how did you removed the Sec-WebSocket-Protocol: arduino?
Requested subprotocol(s) not supported: arduino
is a good hint.
the client sends:Sec-WebSocket-Protocol: arduinothe Server seams to not accept this.
you can try to remove this line:
https://github.com/Links2004/arduinoWebSockets/blob/master/src/WebSocketsClient.cpp#L369
if its working i can a option to disable/override it, then you can add something your server allows.
I'm having the same issue but I'm unable to remove it. does it have an option to disable it? or which line should I remove? I'm using latest version so perhaps it changed.
Most helpful comment
normally not.
add
configTime(3 * 3600, 0, "pool.ntp.org", "time.nist.gov");to the setup and it will be gone.try to enable debug to see the reason for the disconnect.
https://github.com/Links2004/arduinoWebSockets/blob/master/src/WebSockets.h#L30