Issue
Can someone please show me an example on how to establish the connection to the wss:// address with specific Authorization header, using okhttp3 okhttp-ws library?
All I have is the url of WS server and Authorization string token.
Later, I must be able to send request to that connection, listen to upcoming data from WS server and than close connection. I have a difficulties with this new to me WS world, always been working only with REST (with okhttp3 too)
Solution
So generally this sample is most of what you need
But you will have two changes
Use wss instead of ws in your URL
Call request.addHeader to add your token
request.addHeader("Authorization", "Bearer " + token)
Answered By - Yuri Schimke Answer Checked By - Marie Seifert (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.