question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Client side RxJS WebSocketSubject with WsAdapter example not working

See original GitHub issue

I’m submitting a…


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

I’m trying to extend the gateways ws example (working), but using rxjs WebSocketSubject on the client side.

Expected behavior

I’d expect it to work similar to the WebSocket client that is native to the browser (like in that ws gateway example)

Minimal reproduction of the problem with instructions

https://github.com/CoreyCole/nest/tree/master/sample/20-gateways-ws-client-rxjs

What is the motivation / use case for changing the behavior?

RxJS all the things?

Environment


Nest version: 5.0.0
 For Tooling issues:
- Node version: v8.11.1 
- Platform:  Mac

Others:

On the client, I’m using rxjs cdn as instructed here

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
CoreyColecommented, May 17, 2018

Got it working with 6.1.0 on the client! I was just using it wrong. See working: https://github.com/CoreyCole/nest/blob/master/sample/20-gateways-ws-client-rxjs/client/index.html


<html>

<head>
    <script src="https://unpkg.com/@reactivex/rxjs@6.1.0/dist/global/rxjs.umd.js"></script>
    <script>
        const { WebSocketSubject } = rxjs.webSocket;
        const socket$ = new WebSocketSubject('ws://localhost:8080');
        socket$.subscribe(
                (data) => console.log(data),
                (err) => console.error(err),
                () => console.warn('Completed!')
            );
        // rxjs websocket automatically serializes JSON as of version 6.0.0
        // no need for JSON.stringify
        // see https://github.com/ReactiveX/rxjs/blob/master/CHANGELOG.md#600-beta4-2018-03-29
        socket$.next({
            event: 'events',
            data: 'test',
        });
        console.log('here')
    </script>
</head>

<body></body>

</html>
0reactions
lock[bot]commented, Sep 24, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using RxJS 6.x WebSocketSubject client - Stack Overflow
I got it working with rxjs@6.1.0 . As I suspected, I was just using the version 6 syntax wrong. See working example:
Read more >
webSocket - RxJS
webSocket is a factory function that produces a WebSocketSubject , which can be used to make WebSocket connection with an arbitrary endpoint. webSocket...
Read more >
Angular 9 RxJs Websockets / WebSocketSubject not recieving ...
Coding example for the question Angular 9 RxJs Websockets / WebSocketSubject not recieving message from server-rx.js.
Read more >
Auto WebSocket Reconnection with RxJS (with Example)
In this RxJS tutorial article, we will focus on restoring the websocket connection when using RxJS library.
Read more >
Real-Time in Angular: A journey into Websocket and RxJS
I'll be using Angular 8 for the client, Node.js for the server which uses the ... As WebSocketSubject is nothing but a regular...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found