Hello all,
I try to creat a very simple websocket application for a esp32 sensor.
The protocol of the sensor is very easy
1. Connect to ws://IP:654 via websocket client
2. Returned value is "{"type":"Auth"}"
3. Send {"type":"auth", "command":"logmein"}
4. Returned value is "{"type":"Authok"}"
5. Than send a request like "{"type":"sensor", "value":"get"}"
3.returned value is "{"type":"sensor", "value":"55"}"
But I failed already with the first connection
Here is my code
Used library is
org.eclipse.jetty.websocket.api.Session
Error is
Web socket connect failed " + uri.toString(), e);
Can someone help me please??
I try to creat a very simple websocket application for a esp32 sensor.
The protocol of the sensor is very easy
1. Connect to ws://IP:654 via websocket client
2. Returned value is "{"type":"Auth"}"
3. Send {"type":"auth", "command":"logmein"}
4. Returned value is "{"type":"Authok"}"
5. Than send a request like "{"type":"sensor", "value":"get"}"
3.returned value is "{"type":"sensor", "value":"55"}"
But I failed already with the first connection
Here is my code
Java:
try {
URI uri;
uri = new URI("ws://" + ip + ":845");
try {
webSocketClient.start();
} catch (Exception e) {
logger.warn("Web socket start failed", e);
// throw new IOException("Web socket start failed");
}
try {
Session=webSocketClient
.connect(this, uri, new ClientUpgradeRequest()).get();
} catch (Exception e) {
logger.warn("Web socket connect failed " + uri.toString(), e);
// throw new IOException("Web socket start failed");
}
} catch (URISyntaxException e) {
logger.debug("Initialize web socket failed", e);
}
Used library is
org.eclipse.jetty.websocket.api.Session
Error is
Web socket connect failed " + uri.toString(), e);
Can someone help me please??