socketio 5.0.1上的socketio xhr池错误/web套接字错误

toe95027  于 2021-06-29  发布在  Java
关注(0)|答案(0)|浏览(408)

我在做这个了不起的项目。网络浏览器,docker,nginx一切正常。。。但目前在android java客户机上遇到了麻烦。每次进行socketio会话时都会保持响应:

D/socketio: xhr poll error
    V/socketio: xhr poll error -> Errors :: a.a.b.a.a: xhr poll error

内部版本.gradle:

implementation 'io.socket:engine.io-client:2.0.0'
    implementation 'io.socket:socket.io-client:2.0.0'

导入:

import io.socket.emitter.Emitter;
    import io.socket.engineio.client.Socket;
    import io.socket.engineio.client.Transport;
    import io.socket.engineio.client.transports.Polling;
    import io.socket.engineio.client.transports.PollingXHR;
    import io.socket.engineio.client.transports.WebSocket;

android studio-java代码(客户端):

Socket.Options options = new Socket.Options();
    options.transports = new String[]{PollingXHR.NAME, Polling.NAME, WebSocket.NAME};
    Log.d("socketio", "socketio: " + options.toString());
    try {
        socket = new Socket("http://10.10.10.212/socket.io/", options);
        socket.on(Socket.EVENT_OPEN, new Emitter.Listener() {
            @Override
            public void call(Object... args) {
                Log.i("socketio", "open");
            }
        });
        socket.on(Socket.EVENT_ERROR, new Emitter.Listener() {
            @Override
            public void call(Object... args) {
                Exception err = (Exception) args[0];
                Log.i("socketio", "error:" + err.toString());
            }
        });
        socket.on(Socket.EVENT_PACKET, new Emitter.Listener() {
            @Override
            public void call(Object... args) {
                Log.i("socketio", "packet");
            }
        });

        socket.on(Socket.EVENT_DRAIN, new Emitter.Listener() {
            @Override
            public void call(Object... args) {
                Log.i("socketio", "drain");
            }
        });
        socket.open();
        Log.i("socketio", "open...");

    } catch (Exception e) {
        e.printStackTrace();
    }

python socketio服务器:

flask_socketio==5.0.1
    python-engineio==4.0.0
    python-socketio==5.0.4

web浏览器可与以下各项完美配合使用:

<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/3.0.4/socket.io.js" crossorigin="anonymous"></script>

我怎样才能解决这个问题?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题