Questions tagged websocket

Explore the latest questions and answers asked by our top developers.

Where is the right place to unsubscribe from a webSocket in an angular component?

I think we could unsubscribe from a webSocket in the ngOnDestroy of a component, but I am not sure if this is the right place to put it on. What do you think is the right place to do that? Source: Angular Questions

By Belham
Published
Categorized as angular, java-websocket, websocket Tagged , ,

Node.js Websocket don’t work on hosting server

I’m trying to make Angular application with API in Node.JS. On my local machine everything works well but when I’m push API to remote server I’m getting error from WebSocket: WebSocket connection to <URL> failed: WebSocket is closed before the connection is established. There is no place when I use ws.close() so I think that […]

By Ravn
Published
Categorized as angular, hosting, node.js, socket.io, websocket Tagged , , , ,

In SPA application – disconnect socket connection on browser page refresh

In my angular application, I have written code to disconnect socket on ngOnDestroy lifecycle hook that is executed when we navigate to some other page and the component is destroyed. But the problem arises when the whole application is refreshed by hitting on the browser refresh event, which doesn’t execute the ngOnDestroy event of the […]

Notify Client, Angular, from Server, .net, that the thread is complete

I have created a thread to search the data from table, I takes a lot of time and cause request time, to solve that problem I run the method in thread but now how can I notify the client that the server is ready to send the results. I know I’ve to use socket but […]

By COVID -19
Published
Categorized as .net, angular, c#, socket.io, websocket Tagged , , , ,

Multiple websocket connections with different URL

I have a problem connecting simultaneously to several WebSockets with different URLs. So far I used the following methods to connect to a given socket from the URL (one at a time) or send a message to one and disconnect immediately after the Send() method, and then create a new one. In this case I […]

By mrKorny
Published
Categorized as angular, javascript, rxjs, websocket Tagged , , ,

Angular + Spring boot Websocket cors error

I am developing a websocket locally with Spring boot and Angular 12. I have been reading a lot of tutorials but I am having a weird Cors error. The Angular code to connect to the socket is the following: import { Injectable } from ‘@angular/core’; import { NotificationWebSocket } from ‘../model/NotificationWebSocket.model’; import { Stomp } […]

By Gabriel Garc a Garrido
Published
Categorized as angular, cors, spring-boot, websocket Tagged , , ,

Problem with connexion to webSocket when it’s called multiple times successively

i’m working with websocket springBoot in the backend and angular in the front end and i’m using SockJS, and i need to call tree different calls of connexion to websocket in the frontEnd i have a problem with the function to connect, actually i was using this one public async initWebSocket() { return new Promise<void>((resolve,reject) […]

Close the Websocket connection when tab closes

I have an Angular with ng2-stompjs and socksjs client and Spring boot Websocket server. What I want to do, is disconnect from Websocket when a current browser tab is closed. @Component({ selector: ‘app-test-list’, templateUrl: ‘./test-list.component.html’, styleUrls: [‘./test-list.component.css’] }) export class TestListComponent implements OnInit, OnDestroy { // Stream of messages private subscription: Subscription; public messages: Observable<Message>; […]

By aleks Koptev
Published
Categorized as angular, sockjs, stompjs, websocket Tagged , , ,

Angular app not connecting to Mosquitto Test website (test.mosquitto.org)

I’m in the same situation of this guy: Unable to connect to test.mosquitto.org for testing. I’m using angular and I’m trying to call the mqtt mosquito test website. I’ve followed this tutorial and I’m getting the following error: WebSocket connection to ‘wss://test.mosquitto.org:8080/’ failed: My mqtt property in the environment file is configured this way: mqtt: […]

By Federico
Published
Categorized as angular, mqtt, websocket Tagged , ,

Angular websokcet and behaviorSubject unit test

Getting error with websocket unit test Error: <spyOn> : webSocket is not declared writable or has no setter Usage: spyOn(<object>, <methodName>) here’s my service and component // tikcet.service.ts import { webSocket } from ‘rxjs/webSocket’; export class ticketService { ticketVar: number = 0; private ticketCtrl = new BehaviorSubject(this.ticketVar); setTicketSubject(value: number) { this.ticketCtrl.next(value) } getTicketSubject() { return […]

1 2 3 17

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq