JS Client Azure Web PubSub - Messages are getting send after delay of 80-85seconds

Rajesh Shah 20 Reputation points
2023-06-15T10:33:06.7933333+00:00

I am using the Pub-Sub service to send/receive messages between client and server.
using JS version on client as well as server

Client

"@azure/web-pubsub-client": "^1.0.0-beta.3",

Server

"@azure/web-pubsub": "^1.1.1",
"@azure/web-pubsub-express": "^1.0.4",

Once I create client and start sending message to group OR send message to server, it works well.
I have configured URL in Resource so that I am able to receive custom messages to my middleware.

The moment I send message to server using

await client.sendEvent('message', 'Client is ready', 'text', {fireAndForget: true});

and after that if I send any message to group, it takes approx 80-85 seconds to receive other group members.
No console error on client side or server side.
But on LiveTraceTool, I can see one exception.

{"time":"2023-06-14T07:30:54.7972607Z","logLevel":"Warning","eventName":"HttpInvocationFailed","message":"Failed invoking 'https://5dd1b8bbaa56.ngrok.app/eventhandler?hub=captionmeeting&event=x' for 'hub:captionmeeting,event:message,type:user,category:messages,requestType:UserEvent'.","exception":"The request was canceled due to the configured HttpClient.Timeout of 100 seconds elapsing."}

Any idea about this particular error?
Once I receive this error on tool, after that it works smoothly and no problem occurs afterwards.
Is there anything which I am missing ?

Middleware code (using express library)

let handler = new WebPubSubEventHandler(HUB_NAME, {   
path: '/eventhandler', // Exposes an endpoint    
onConnected: async (req) => {     
	console.log(`${req.context.userId} connected`);   	
	},      
onDisconnected: async (req) => { 
   	console.log(req)   	
	},     
// This handler function will handle user system     
handleUserEvent: async (req, res) => {  
       if (req.context.eventName === "message") { 
      		console.log(`Received message: ${req.data}`);      	
	}   
}   
})

Region hosted: Germany West Central
Hub setting
User's image

Any help will be appreciated!
Thanks

Azure Web PubSub
Azure Web PubSub
An Azure service that provides real-time messaging for web applications using WebSockets and the publish-subscribe pattern.
60 questions
JavaScript API
JavaScript API
An Office service that supports add-ins to interact with objects in Office client applications.
870 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
6,900 questions
{count} votes

Accepted answer
  1. Liangying Wei 756 Reputation points Microsoft Employee
    2023-06-21T02:30:01.15+00:00

    Please call res.success in your handleUserEvent to write the response back to the service.

    handleUserEvent: async (req, res) => {  
           if (req.context.eventName === "message") { 
          		console.log(`Received message: ${req.data}`);      	
    	}
        res.success();   
     }  
    

0 additional answers

Sort by: Most helpful