'Android Java Socket Io Emitter can't send message

For a few days I've been trying to get the socket.io chat example to work from here. First I tried it by typing everything myself. But it didn't work. Every time i get this error.

Attempt to invoke virtual method 'io.socket.emitter.Emitter io.socket.client.Socket.emit(java.lang.String, java.lang.Object[])' on a null object reference

I am getting messages from server, but when i am trying to send i am always getting that error. If i am just trying send String getting same error

Here i am connecting

IO.Options options = new IO.Options();
    SocketSSL.set(options);
    Socket mSocket = null;
    try {
        mSocket = IO.socket("https://gaidena.lt:3000", options);
    } catch (URISyntaxException e) {
        e.printStackTrace();
    }
    mSocket.connect();
    mSocket.on("get", onNewMessage);

and here trying to send message

private void attemptSend() {
    String message = editTextMessage.toString().trim();
    if (TextUtils.isEmpty(message)) {
        return;
    }

    mSocket.emit("send", message);
}

here getting messages

private Emitter.Listener onNewMessage = new Emitter.Listener() {
    @Override
    public void call(final Object... args) {
        getActivity().runOnUiThread(new Runnable() {
            @Override
            public void run() {
                Log.d(TAG, args[0] + "");
            }
        });
    }
};


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source