获取http://127.0.0.1:8000/socket.io/?EIO=3&transport=polling&t=LFCDzs3 404(未找到)Socket.io Java客户端

时间:2016-03-31 10:35:16

标签: javascript java socket.io

我正在使用socket.io java client https://github.com/socketio/socket.io-client-java

显然,从那时起我一直坚持这个错误。

以下是我的代码:

socket = IO.socket("http://127.0.0.1:8000");
            socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {

                @Override
                public void call(Object... args) {
                    System.out.println("Connection Successful");
                    socket.emit("foo", "hi");
                }
            });

            Socket sock = socket.connect();
            System.out.println(sock);

        }catch(URISyntaxException exception){

            exception.printStackTrace();

        }

javascript部分如下:

<script>
  var socket = io.connect('http://127.0.0.1:8000');
  socket.on('connect', function(){
    console.log("Hi! I am on");
  });
  socket.on('event', function(data){
    console.log(data);
  });
  socket.on('disconnect', function(){
    console.log("Bye! I am off");
  });
</script>

任何解决方案?

0 个答案:

没有答案