ngx-socket-io icon indicating copy to clipboard operation
ngx-socket-io copied to clipboard

forceNew config option not supported

Open gs-scooter opened this issue 4 years ago • 2 comments

Using Angular 12 / Typescript.

The SocketIOConfig interface does not support a forceNew option. This results in a compile-time error when attempting to use it due to a type assignment failure.

gs-scooter avatar Jul 20 '21 19:07 gs-scooter

If it helps, I faced a similar issue where I had to use withCredential option. I downgraded to use the 4.0.0 version which was before the SocketIoConfig fixed interface was implemented and it works for me.

ThamMK avatar Jul 26 '21 10:07 ThamMK

Same here. I was just upgrading my server and client to latest versions and received that error. After downgrading to 4.0.0 it is working again. Thanks.

nosTa1337 avatar Jul 28 '21 10:07 nosTa1337

I faced the same problem but couldn't downgrade because in my case I need angular 15. So for anyone in this case you can just add this in the declaration of the class SocketIoConfig in the file locate in \node_modules\ngx-socket-io\src\config\socket-io.config.d.ts

export interface SocketIoConfig {
    url: string;
    /**
     * Options
     * References:
     * https://github.com/socketio/socket.io-client/blob/master/docs/API.md#new-managerurl-options
     */
    options?: {
        /**
         * Name of the path that is captured on the server side. Default: /socket.io
         */
        path?: string;
//....
        forceNew?: boolean
    };
}

This will allow you to use the forceNew option. I know this is not a long-term fix but it might do the trick before authors fix the problem.

Captainfl4me avatar Jan 03 '23 10:01 Captainfl4me