exception handling in ngx-socket-io angular

247 views Asked by At

In angular, SocketIoModule.forRoot(config) in app.module.ts keeps on trying to connect with localhost 8080 which is not running currently


const config: SocketIoConfig = {
    url:"http://localhost:8080/",
    options: {},
};


@NgModule({
..
imports: [
....
SocketIoModule.forRoot(config),
...
]
}

enter image description here

It should be try to connect to the socket server once and stop if there is some kind of error( in my case ERR_CONNECTION_REFUSED).

how to handle this exception in ngx-socket-io? little help will be appreciated

1

There are 1 answers

0
Althaf On BEST ANSWER

solved it by adding additional option in SocketIoConfig.

const config: SocketIoConfig = {
    url:"http://localhost:8080/",
    options: { reconnection:false},
};