Anyone try with Chat WSS ?

Today I try to connect to chat WSS and I got this error:

{“content”:“ILLEGAL_PARAM”,“self”:false,“type”:“error”}

I replace listenKey and listentoken and put wss format as FAQ:
wss://im.binance.com:443/chat/c2c_xxxxxxxxxxxxxx?token=TOKENxxxxxxxxx&clientType=web

Where did you obtain wss://im.binance.com:443 URL ?

from here: P2P Merchant Portal

5.4 SAPI notification and chat related FAQ

Q1: How to get notifications of orders or chat?

It can be found In the response of this API

/sapi/v1/c2c/chat/retrieveChatCredential

Then, get the wss url and the credential as following

{
    ""code"": ""000000"",
    ""message"": ""success"",
    ""data"": {
        ""chatWssUrl"": ""wss://im.binance.com:443/chat"",
        ""listenKey"": ""c2c_xxxxxxxxxxxxxx"",
        ""listenToken"": ""TOKENxxxxxxxxx""
    },
    ""success"": true
}

Next, you should connect to wss by

wss://im.binance.com:443/chat/c2c_xxxxxxxxxxxxxx?token=TOKENxxxxxxxxx&clientType=web

Finally resolve the problem.

The problem come from calling the retrieveChatCredential API incorrectly.

Change “clientType”: ‘any’ to “clientType”: ‘web’ had fixed the problem.

@Hen_Si Thank you.
My socket is connected, and new messages are received.
Please help me how to send message via socket

2 Likes

So how to send messages to chat, somebody know?

No issues recieving messages. Trying to send messages getting ‘true’ response but no messages showing up in the chat. anyone get this working?