我正在尝试通过websocket协议连接到以太网模块。我已经使用javascript和nodejs成功连接到模块。但是我想用java创建一个独立的应用程序。
我使用以下库https://github.com/TooTallNate/Java-WebSocket并成功连接到nodejs套接字服务器。但是相同的代码无法连接到所述以太网模块,该模块通过javascript和节点js成功连接。
我已尝试过这两个示例代码。
https://github.com/TooTallNate/Java-WebSocket/wiki#user-content-client-example
Processing - how to send data (through websockets?) to javascript application
登录成功连接:
write(153): {GET / HTTP/1.1
host: localhost:9991
upgrade: websocket
connection: Upgrade
sec-websocket-version: 13
sec-websocket-key: tJQdsjTjLaoNzW5lzPh3pA==
}
process(129): {HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: 4s+UFW9gNz7iCNRLE0aK5ohjl00=
}
open using draft: Draft_17
记录连接失败:
write(157): {GET / HTTP/1.1
host: 192.168.1.10:6432
upgrade: websocket
connection: Upgrade
sec-websocket-version: 13
sec-websocket-key: ZQMlepwV8lqyuSglz/Qx2Q==
}