How to configure signal R to send requests to KONG API with bearer token. I am able to get connection token from negotiate version but not able to maintain the connection. I am passing headers as web socket but it's still not able to keep the connection a

Swathi Maley 0 Reputation points
2024-06-27T16:11:46.0633333+00:00

How to configure signal R to send requests to KONG API with bearer token. I am able to get connection token from negotiate version but not able to maintain the connection. I am passing headers as web socket but it's still not able to keep the connection alive.

My UI code

useEffect(() => {

    let header = {

        'Authorization': "Bearer " + token,

        connection: 'Upgrade',

        host: 'my-websocket-api.com',

        upgrade: 'WebSocket'

    }

    // Establish the connection to the SignalR hub

    const newConnection = new HubConnectionBuilder()

        .withUrl(GET_SIGNALR_ENDPOINT_Secured, {

            transport: HttpTransportType.ServerSentEvents,

            withCredentials: false,

            transport: HttpTransportType.ServerSentEvents,

            accessTokenFactory: () => { return userSession?.dispensingToken },

            **headers: header,**

           httpClient: new CustomHttpClient(),

        })

        .build();

    setConnection(newConnection);

}, []);

useEffect(() => {

    if (connection) {

        connection.start()

            .then(() => {

                console.log('Connected to the hub');

                });

                setIsHubConnected(true);

            })

            .catch(err => console.error('Connection failed: ', err));

    }

}, [connection]);
Azure SignalR Service
Azure SignalR Service
An Azure service that is used for adding real-time communications to web applications.
136 questions
0 comments No comments
{count} votes