Java Socket Server with JavaScript Client -
i put java socket server , client can send messages each other, want use javascript client, but... here happens when i'm hosting java server , load javascript client.
javascript:
var connection = new websocket('ws://127.0.0.1:9005'); connection.onopen = function () { connection.send('ping'); };
this prints in chrome console:
websocket connection 'ws://127.0.0.1:9005/' failed: error during websocket handshake: invalid status line
websocket error [object event]
what i'm trying send "ping" java server, instead sends stuff disconnects...
this prints in java server console:
bread server running...
new connection from: 127.0.0.1:51948
127.0.0.1:51948: / http/1.1
127.0.0.1:51948: host: 127.0.0.1:9005
127.0.0.1:51948: connection: upgrade
127.0.0.1:51948: pragma: no-cache
127.0.0.1:51948: cache-control: no-cache
127.0.0.1:51948: upgrade: websocket
127.0.0.1:51948: origin: http://markstuff.net
127.0.0.1:51948: sec-websocket-version: 13
127.0.0.1:51948: user-agent: mozilla/5.0 (windows nt 6.1; wow64)
applewebkit/537.36 (khtml, gecko) chrome/48.0.2564.103 safari/537.36
127.0.0.1:51948: accept-encoding: gzip, deflate, sdch
127.0.0.1:51948: accept-language: en-us,en;q=0.8
127.0.0.1:51948: sec-websocket-key: d4epyc7lwvpdfedwg0sy2g==
127.0.0.1:51948: sec-websocket-extensions: permessage-deflate; client_max_window_bits
127.0.0.1:51948:
error: software caused connection abort: recv failed
javascript client: markstuff.net/socket/ - markstuff.net/socket/client.js
java server: pastebin com cdzjuwqp
java client: pastebin com efeeezcr
sounds trying connect websocket client bare socket listener in server side. notice websocket not equal socket. websocket protocol on top of tcp connection (like how http on top of tcp) .
should either change server implementation websocket (you can find many java websocket libraries in internet) or change client socket.
i'm not sure how create socket connection in js topic maybe helpful problem: connecting tcp socket browser using javascript
Comments
Post a Comment