When putting a basic example code in place, the following error message is shown on screen:
Microsoft.Azure.WebJobs.Host: Error indexing method 'negotiate'.
Microsoft.Azure.WebJobs.Extensions.SignalRService:
The SignalR Service connection string must be set either via an 'AzureSignalRConnectionString' app setting,
via an 'AzureSignalRConnectionString' environment variable,
or directly in code via SignalROptions.ConnectionString or SignalRConnectionInfoAttribute.ConnectionStringSetting.
So, we populated SignalRConnectionInfoAttribute.ConnectionStringSetting with a proper connection string obtained from Azure SignalR Service but the following error message is shown:
Error indexing method 'negotiate'
Microsoft.Azure.WebJobs.Host: Error indexing method 'negotiate'. Microsoft.Azure.WebJobs.Host: Unable to resolve the value for property 'SignalRConnectionInfoAttribute.ConnectionStringSetting'. Make sure the setting exists and has a valid value.
The connection string format is like: Endpoint=https://mysignalrservice.service.signalr.net;AccessKey=mymaskedkey=;Version=1.0;
The function is 2.x and utilizes .net core 2.2. Is there an explanation for this problem or how to resolve it?
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
Hi @Arash-Sabet Thank you for your feedback! We will review and update as appropriate.
@Arash-Sabet Just checking if you have gone through the Create with Azure Functions and SignalR Service doc and GitHub samples.
@DixitArora-MSFT The point is that the document should be self-contained and thorough enough to help the reader understand the existese of the basic dynamics. Basics cannot be deferred to other web pages, articles, or git repositories found somewhere remote on the web.
The problem that I brought up has a solution per the following sample that needs to be incorporated within "local.settings.json" file in VS 2017 but it should have been included in this document. Now the next question that may raise is that whether the reader would know where to apply this change in hosted functions on cloud.
Would you please update this document accordingly? Thanks.
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"AzureWebJobsDashboard": "UseDevelopmentStorage=true",
"AzureSignalRConnectionString": "Endpoint=https://myendpointservice.signalr.net;AccessKey=maskedkey;Version=1.0;"
},
"Host": {
"LocalHttpPort": 7071,
"CORS": "*"
}
}
@Arash-Sabet I have assigned this to content author to review and update as appropriate.
Can you please post a client JavaScript example which would be able to negotiate with the following function? Please elaborate on how a header can be included in the JavaScript call to be able to communicate with this function to negotiate? Is it possible at all?
[FunctionName("negotiate")]
public static SignalRConnectionInfo Negotiate(
[HttpTrigger(AuthorizationLevel.Anonymous)]HttpRequest req,
[SignalRConnectionInfo
(HubName = "chat", UserId = "{headers.x-ms-client-principal-id}")]
SignalRConnectionInfo connectionInfo)
{
// connectionInfo contains an access key token with a name identifier claim set to the authenticated user
return connectionInfo;
}
Same problem for me. I'm not sure why the binding is not working.
In my function.json I have:
"bindings": [
{
"authLevel": "anonymous",
"type": "httpTrigger",
"direction": "in",
"name": "req"
},
{
"type": "http",
"direction": "out",
"name": "res"
},
{
"type": "SignalRConnectionInfo",
"name": "connectionInfo",
"hubName": "chat",
"connectionStringSetting": "Endpoint=https://myapp.service.signalr.net;AccessKey=myappkey;Version=1.0;",
"direction": "in"
}
]
@dixitArora-MSFT can you ask the author to provide example of function.json that has the bindings?
@Arash-Sabet - the negotiate endpoint is consumed when you start the connection:
var connection = new signalR.HubConnectionBuilder()
.withUrl(`${apiBaseUrl}/api`)
.configureLogging(signalR.LogLevel.Information)
.build();
connection.start()
If you check your network logs, you'll see that the /api/negotiate endpoint has been consumed.
I encountered the same issue. I suspected the local.settings.json file was disregarded when running locally. I found a hint here: -https://stackoverflow.com/questions/52194154/unable-to-read-local-settings-json-file-when-running-azure-function-locally
Make sure your local.settings.json file is marked to always be copied to the build output. (by right clicking on it in Visual studio). This will copy your files to the output path similar to bin\debug..
I guess this issue is because author used VS and I was using VS Code.
Then I created/copied the whole app (JS one) to a new project then it worked!!
Another issue i faced was an "Connection Handshake Error". It might be useful for someone and not waste 3 hours finding out the culprit.
For this I found then hint here:- https://docs.microsoft.com/en-us/azure/azure-signalr/signalr-resource-faq
The Client connection closes with the error message "No server available". What does it mean?
This error occurs only when clients are sending messages to the SignalR Service.
If you don't have any application server and use only the SignalR Service REST API, this behavior is by design. In serverless architecture, client connections are in LISTEN mode and will not send any messages to SignalR Service. Read more on REST API.
If you have application servers, this error message means that no application server is connected to your SignalR Service instance.
The possible causes are:
No application server is connected with SignalR Service. Check application server logs for possible connection errors. This case is rare in high availability setting with more than one application servers.
There are connectivity issues with SignalR Service instances. This issue is transient and will automatically recover. If it persists for more than an hour, open an issue on GitHub or create a support request in Azure
So I changed my Azure SignalR Service from default to Classic Mode.
This should be mentioned in the https://docs.microsoft.com/en-us/azure/azure-signalr/signalr-quickstart-azure-functions-javascript Doc!