Open Vikas252 opened 1 year ago
Where do you expect to start the connection? In Number1 looks like you are trying to start the connection from inside the Negotiate function. Could you describe your scenario a little bit more?
@vicancy Thank you for the response the scenario can be like The system is built on nodejs with express multiple express routes, consist of handlers for different routes on of them is the negotiate route through which the signalR connection end point URL and access Token is obtained
I need to access or open websocket mode for serverless on a particular page when the user clicks maybe a different route, to communicate with my angular frontend so to connect the signalR in my backend when i get the connection endpoint and access token i have a controller which handles the connection for signalR so there i create a new connection with the existing json i received from the negotiate function called.
When tried with the controller it says
Error from HTTP request. TypeError: Cannot read properties of undefined (reading 'secure').
For the response of negotiate function i called it explicitly from postman for testing in the above scenario
I did a quick try on creating a negotiate
function and it is successfully connected locally using the latest core tool version 4.0.5198
. Here is my steps:
npm i -g azure-functions-core-tools
samples/QuickStartServerless/javascript
AzureSignalRConnectionString
to your Azure SignalR connection stringnegotiate
(to avoid other dependencies)npm i --save @microsoft/signalr
Update negotaite/index.js to
const { HubConnectionBuilder, HttpTransportType, LogLevel } = require("@microsoft/signalr");
module.exports = async function (context, req, connectionInfo) {
const connection = new HubConnectionBuilder()
.withUrl(`${connectionInfo.url}`, {
accessTokenFactory: () => `${connectionInfo.accessToken}`,
transport: HttpTransportType.WebSockets
})
.withAutomaticReconnect()
.configureLogging(LogLevel.Debug)
.build();
console.log(connectionInfo);
await connection.start();
context.res.body = connectionInfo;
};
func start
curl -X POST http://localhost:7071/api/negotiate
Debug: HubConnection connected successfully.
Describe the bug
i'm using signalR instance (serverless mode) i have created the bindings for signalR through the serverless framework, once the negotiate route is been hit i get the response but further when i try to connect with the same url and access token received from the negotiate function it gives error of
HubConnection failed to start successfully because of error 'Error: Failed to complete negotiation with the server: TypeError: Cannot read properties of undefined (reading 'secure')'.
To Reproduce
function.json:
Azure function handler (Number 1) i.e server.ts:
Azure function handler (Number 2) i.e server.ts:
Serverless.yml specification:
app.ts:
Exceptions (if any)
If azure handler is Number 1:
If azure handler is Number 2
Further technical details
"azure-functions-core-tools": "^4.0.5148",
"@microsoft/signalr": "^7.0.7",