Closed RogierdeRuijter closed 4 months ago
Found a quick workaround / solution:
const socketConfig: SocketIoConfig = {
url: '/',
options: {
path: '/socket.io',
transports: ['websocket'],
secure: true,
}
};
@Injectable()
export class SocketRunningOutsideOfAngular extends Socket {
constructor() {
super(socketConfig);
}
}
@NgModule({
declarations: [
...
],
imports: [
SocketIoModule
],
providers: [
{
provide: SocketRunningOutsideOfAngular,
useFactory: (ngZone: NgZone) => {
return ngZone.runOutsideAngular(() => {
return new SocketRunningOutsideOfAngular();
});
},
deps: [NgZone]
},
This issue is stale because it has been open for 30 days with no activity.
This issue was closed because it has been inactive for 7 days since being marked as stale.
Hee,
I am currently facing the issue that my E2E tests in protractor time out. And I believe it is an issue related to Protractor, Angular, and SocketIO. Here is an old GitHub Issue mentioning the problem https://github.com/angular/angular/issues/11853.
There is also a fix for it, but this requires setting up the WebSocket connection 'outside of Angular' with the help of NgZone.
So my question is, is there a way to setup the WebSocket connection outside of Angular?
Cheers,
FYI: The library ng-socket-io has a PR open to setup the socket outside of Angular. https://github.com/bougarfaoui/ng-socket-io/pull/61