-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
Describe the bug
I'm using ng2-stompjs with stompjs and sockjs-client for connect to ws. In development mode, all work fine and in the browser and in the desktop version, but after npm run electron:build all interactive UI elements depends on web socket connection are stuck no matter it's the portable version or unpacked. Perhaps some optimization broke that.
To Reproduce
Add to AppModule
import {
RxStompService,
InjectableRxStompConfig,
rxStompServiceFactory,
} from '@stomp/ng2-stompjs';
import * as SockJS from 'sockjs-client';
function socketProvider() {
return new SockJS('http://localhost:8090/api/streams');
}
const myRxStompConfig: InjectableRxStompConfig = {
webSocketFactory: socketProvider,
// Headers
connectHeaders: {
login: 'guest',
passcode: 'guest',
},
heartbeatIncoming: 0, // Typical value 0 - disabled
heartbeatOutgoing: 200, // Typical value 20000 - every 20 seconds
reconnectDelay: 200,
debug: (msg: string): void => {
console.log(new Date(), msg);
},
};
And add to providers:
providers: [
{
provide: InjectableRxStompConfig,
useValue: myRxStompConfig,
},
{
provide: RxStompService,
useFactory: rxStompServiceFactory,
deps: [InjectableRxStompConfig],
},
],
In component.ts:
public message;
constructor(private readonly rxStompService: RxStompService) { }
public subscribeMarketStream() {
this.rxStompService.watch('/stream/dashboard').subscribe((message) => {
this.message = message.body;
});
In component.html
{{ message }}
npm run electron:build
Socket subscription doesn't work after production optimization.
Additional context
- OS: Windows 10
Perhaps I can disable some optimization options and this solves the problem?