Not able to login to websocket: Malformed method invocation

Steps to reproduce:

I am trying to connect to channel via websocket from Flutter application
Tried to use this Map to create login object:

Map msg = {
      "msg": "method",
      "method": "login",
      "id": Random().nextInt(Constants.int32MaxValue),
      "params": [
        {"resume": authToken}


Expected behavior:

As described in the API Docs A successful call will return the same message as a successful login (which it is).

Actual behavior:

Connection happens as expected, while login is unsuccessful

Server Setup Information:

  • Version of Rocket.Chat Server: 3.11.1
  • Operating System: Ubuntu
  • NodeJS Version: v12.20.2
  • MongoDB Version: 4.0.23

Relevant logs:

[log] ws event occurred: {“msg”:“connected”,“session”:“XXXXXX”}
I/flutter (11448): Notification{msg: UNKNOWN, collection: null, serverId: null, subs: null, methods: null, id: null, fields: null, result: null}
[log] ws event occurred: {“msg”:“error”,“reason”:“Malformed method invocation”,“offendingMessage”:{“msg”:“method”,“method”:“login”,“id”:4527266,“params”:[{“resume”:“XXXXXX”}]}}

The problem was the Id object must be a String, not an Int
"id": Random().nextInt(Constants.int32MaxValue).toString(),