Socket.IO 错误尝试在空对象引用上调用虚拟方法 'java.lang.String okhttp3.MediaType.toString()'

Socket.IO error Attempt to invoke virtual method 'java.lang.String okhttp3.MediaType.toString()' on a null object reference

我尝试将我的 android 应用程序连接到 nodeJs 服务器,但它无法正常工作...我收到错误 Attempt to invoke virtual method 'java.lang.String okhttp3.MediaType.toString()' on a null object reference

这是我的 nodeJs 服务器代码

var io = require('socket.io').listen(8080),
dns = require('dns'),
express = require('express'),
mysql = require('mysql'),
interval = 2000,
google = 'www.google.com';

var connect = mysql.createClient({
    host : 'localhost',
    user : 'root',
    password : '',
    database : 'database'
});

io.sockets.on('connection', function (socket) {
    console.log(socket);
})

这是我的 Java 代码...

//importing socket.io dependencies
import io.socket.client.IO;
import io.socket.client.Socket;
import io.socket.emitter.Emitter;

//initializing socket variable
static Socket socket;

try {
    socket = IO.socket(socketUrl);
    socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
        @Override
        public void call(Object... args) {
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    socket.emit("connected", userId);
                }
            });
        }
    });
    socket.connect();
} catch (URISyntaxException e) {
    e.printStackTrace();
}

这是我的日志

E/AndroidRuntime: FATAL EXCEPTION: OkHttp Dispatcher
    Process: com.pixtanta.android, PID: 26214
    java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String okhttp3.MediaType.toString()' on a null object reference
        at io.socket.engineio.client.transports.PollingXHR$Request.onLoad(PollingXHR.java:271)
        at io.socket.engineio.client.transports.PollingXHR$Request.access0(PollingXHR.java:148)
        at io.socket.engineio.client.transports.PollingXHR$Request.onResponse(PollingXHR.java:232)
        at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:519)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
        at java.lang.Thread.run(Thread.java:761)

我还是 Android Studio 的新手,Java...有人知道如何解决这个问题吗?

您正在使用的库中似乎有针对此问题的错误修复

https://github.com/socketio/engine.io-client-java/commit/6f065b7a62603730979d43cec71af0046ca4ab7c#diff-4095582e8c038519a759817bf31dbfd7686a4f58942ad00daaf8201d5f936a3a