1

I am using Websocket Rxjs in my application. My connection gets established with the server and after subscribing to it I receive all the data in an array. Now when I try to send the some data back to the server, it just doesn't send, it get's stored in the buffer array of destination object of websocket observable (screenshot below). I am sharing the snippet of the code also.

 import { webSocket } from 'rxjs/webSocket';

const subject = webSocket('ws://localhost:8081');

subject.subscribe({
  next: msg => console.log('message received: ' + msg),
  error: err => console.log(err), 
  complete: () => console.log('complete') 
});


// Upon clicking a button I send this to the sever. You can see it in the screenshot.
subject.next({
    "action" : "read",
    "id" : 1595
});

enter image description here

My connection remains active though. It doesn't gets closed but still I am facing this issue. What could be the issue with this? Is it something with the backend ? If yes, then what could it be ? Any help will be appreciated. Thank you. :)

2
  • 1
    Do you see any activity in the Network > WS tab of dev tools? Commented Jul 22, 2022 at 9:31
  • @BizzyBob Yes I can see request going to the server and receiving the data in WS tab but when I send anything, it just doesn't work. Commented Jul 26, 2022 at 9:38

1 Answer 1

1

It seems that the problem is in your websocket server, but to be sure try instead to connect to a test server like the echo server of Postman: wss://ws.postman-echo.com/raw

In each time the client sends a message to this server it will send it back to the client directly.

By the way: Postman now has the possibility yo to connect to your websocket server and test it.

Here you can read how to do that: https://blog.postman.com/postman-supports-websocket-apis/

Sign up to request clarification or add additional context in comments.

1 Comment

just seeing this, and downloaded the latest PM desktop app. The websocket thing works well. Following the guide here: postman.com/postman/workspace/websockets/documentation/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.