-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Self-Host or Emulate Azure SignalR Service for serverless local development #969
Comments
yes, I am looking for the exact same thing |
Is Upstream used in your scenario? If we have a very first version of the emulator that only supports SignalR Service output binding, would that help? |
For me, that would be sufficient. |
Same for me, I am only using output. Is that available? |
I am trying to have a very first version this week for you to have a try. |
Emulator Preview VersionFeatures available
NOTEIt is only for serverless scenarios. WalkthroughTake this serverless sample for example: https://docs.microsoft.com/en-us/azure/azure-signalr/signalr-quickstart-azure-functions-javascript?WT.mc_id=signalrquickstart-github-antchu
After the emulator is successfully started, it generates the ConnectionString to be used later, for example, the ConnectionString is
|
I've just got Upstream working in local development! 1. Authentication 2. Public URL for local function First start the functions app: Then I used ngrok to make my local running function available to the internet: 3. Setup Upstream 4. SignalR messages send to the SignalR Service are now forwarded to your local running functions app! This is the code I use to trigger a function with a SignalR message and send back another message:
5. (optional) create a separate development SignalR Service I opted to create a separate SignalR Service for development. You also have to create another functions app instance to get the access key. Using this in combination with hot reloading the local functions instance is going great so far. |
Emulator Preview With Upstream availableFeatures available
WalkthroughTake this serverless sample for example https://github.com/Azure/azure-functions-signalrservice-extension/tree/master/samples/bidirectional-chat
Or update the emulator to the latest preview version if it is already installed:
It inits a default
After the emulator is successfully started, it generates the ConnectionString to be used later, for example, the ConnectionString is
|
Is the emulator working also with Default/Classic mode or only with Serverless mode? I've just migrated to Azure SignalR and went with Default on the portal, which seems to work fine, but not when using the emulator. @vicancy, I'm on
|
No only serverless mode. For {
"Azure": {
"SignalR": {
"Enabled": false
}
}
} |
@vicancy, could you point me at some (recent, up to date) docs regarding that topic? Edit: Do you mean that in Debug/Local I can simply omit
? |
Yes |
@vicancy is there a way to allow the emulator to work with remote connections? I'm trying to use the emulator on my local machine with a Xamarin application running on an Android emulator. Using Edit |
Hello everyone, just wanted to add a few words on something I struggled with, using @vicancy's nice emulator but that I did manage to solve (somehow). If that may help : Problem : My javascript invoke method didn't work : asrs-emulator1.0.0-preview1-10624 Localhost Functions Server
With a simple Hub class that extends And a simple function my client will call using a SignalRTrigger
Resolution : The problem is that the negotiate method returns a token in the
Please note, that it may be a wrong solution or a misunderstanding of how SignalR Service works. |
Hi @amura11 With the latest preview version Hi @Chappitono Thanks for the sharing, so is this an issue for the Emulator only? |
Sorry for my late answer @vicancy Update : I have got the same invocation problem after deploying on Azure : I guess I may have an issue with the bearer token (In the negotiate method, I am sending the same token I got from IdentityServer4). So I will start reading again your samples and doc to find out the problem. |
Thanks @Chappitono for the updates, this might be an issue that our service side need to handle, @zackliu would you mind taking a look if duplicate claims can break serverless scenarios? |
@Chappitono It's a bug in SignalR Trigger. And the solution is still in investigation. |
Just wanted to post that this emulator is a life saver for local development @vicancy . I hope it finds it's way soon onto the official docs. =) |
As above, the emulator has been a life saver, so big thanks @vicancy. That said, when trying to hit the endpoints for to check / delete a connection id (/api/v1/hubs/{hub}/connections/{connectionId}) it will throw a NullReferenceException. From having a quick look, this is because in DynamicHubContextStore, on line 65 it is trying to get CachedHubLifetimeManager<> from the service provider but it is only registered as the implementation for HubLifetimeManager<>. |
@vicancy, The emulator are working fine in local environment but it's not working once deployed function app and configured upstream settings in Azure portal. I can do only negotiate apart from no other response . Any reason? |
@Prabumca12 does the client see any exception message when invoking methods? @JagKing Thanks for reporting the issue, however I failed to repro it locally, could you share the repro step? |
Yes @vicancy. I'm getting below issue in client side |
Sure. Version: Steps:
A few other things:
|
[Updated typo] @JagKing please try |
@vicancy , Yeah sure . I will share code with you before I would like also know below upstream settings configured in azure portal are correct format or not? let me know I missed anything |
@vicancy Did you mean |
@Prabumca12 Are you using azure function with SignalR Trigger, you should configure the url like We have a step by step sample for upstream https://github.com/aspnet/AzureSignalR-samples/tree/master/samples/BidirectionChat |
@zackliu. Yes . I have tried below configuration but it's not working |
@vicancy a couple of questions,
Also, do you have a reference available for the environment options available for this? I've tried to find documentation but cannot locate any. |
@LukeBolly no it does not override azure-signalr/src/Microsoft.Azure.SignalR/Startup/AzureSignalRHostingStartup.cs Lines 21 to 23 in 4010da1
So please remove your AddAzureSignalR() if you are using this configuration. But it is really a good catch, creating an issue to track it: #1151
No not for now, we should add, thanks for pointing this out. |
I'm running into an issue where I'm trying to send a message through the emulator and Newtonsoft is failing to parse the message. The upstream works and the function app's function is triggered. However, the function app throws
Looking at the web socket messages, the message to the SignalR emulator over web socket ends with a unicode char:
The unicode char is \u1e or 9633. Seems Newtonsoft is dying on that. No one else is experiencing this? I know Default uses this as a message divider but it seems the serverless isn't properly handling that? Is it possible to turn it off? I don't see anything in the doco about that. I'm using an
|
@mmulhearn |
@vicancy This is the message being sent to the function (with my data removed)
|
FYI, I also cloned the sigr repo and ran the emulator there with the same outcome. |
Played around with it a bit more and it seems to only happen if your HttpTrigger is bound to |
@vicancy, when will there a be a public nuget package available? |
The latest preview version is now available in NuGet. https://www.nuget.org/packages/Microsoft.Azure.SignalR.Emulator |
If you do not need the Upstream functionality there is a simple emulator project I created a year ago: |
No problems since I run my own emulator 😂 |
I am also noticing the issue that @mmulhearn describes above - I have raised #1262 for this. |
@vicancy Do you know if the emulator works with the Management SDK and the Persistent (websocket) Transport? |
Don't worry, I found my answer: https://github.com/Azure/azure-signalr/blob/dev/docs/emulator.md#azure-signalr-local-emulator "Please also note that emulator only works for Transient transport type (the default one) and doesn't work for Persistent transport type." Is this something that's likely to be added? |
There is currently no plan to. The emulator is designed to make local debugging easier. Since the development experience for using Transient mode and Persistent mode should be the same, the emulator sounds already achieved its goal by supporting Transient mdoe. |
My ServerlessHub isn't capturing the OnConnected Events but clients have no issues getting a connectionId via Negotiate function. I read a post to use Azure SignalR Emulator. when I do, I still don't get OnConnected event handler getting call and I noticed this error noted below but no further details are provided and there doesn't seem to be a verbose logging option. Any suggestions?
FYI, this is the event I am trying to handle (even removing this from my ServerlessHub class I still get the noted error/warning):
|
Have you configured the upstream settings? The hub name is |
Yes, I have configured the upstream settings and yes it matches, "negotiatesignalr". Like I mentioned, my clients are able to connect through the Negotiate function (which reaches out to Azure to get access_token) and the client can get a connectionId. All the HTTP communication works, but none of the non-HttpTrigger functions seem to work (OnConnected or my custom message functions) and there is an issue with being able to get the OnConnected event to get to the handler function as there is an error getting thrown as noted in my previous post. So you being able to repro on your end may not be doable and I am more looking into having Azure SignalR Emulator to provide more details as to why the noted error occurred as having, "An error occurred while sending the request." is a good start but no nearly enough details to look into this issue. Even without Azure SignalR Emulator running the OnConnected event doesn't get triggered, here is my Negotiate function, which works fine:
|
Further testing, it seems transport was not set and I needed to set this setting, "transport: HttpTransportType.WebSockets": this.hubConnection = new HubConnectionBuilder() And when I do, I get this error and not sure if this created a new issue or just allowed me to view the actual error that is getting thrown for my SignalRTrigger function?: Error invoking MyCustomSignalRTriggerFunction method: Error: Invocation failed, status code 500 And with or without Azure SignalR Emulator, I see this getting sent from the Network tab (HTTP Status Code 101 - Changing Protocol) to: wss://my-demo.service.signalr.net/client/?hub=negotiatesignalr&id=[some-id]&access_token=[my-token] with the following Messages over this wss socket connection (seems this may be getting blocked on my local machine?): |
Hi @JPL-Alliant , is what described here #1926 work for you? I am updating the emulator to print the full exception, before the package release, one way to debug your issue might be local running the emulator project to see what throws https://github.com/Azure/azure-signalr/tree/dev/src/Microsoft.Azure.SignalR.Emulator |
Hello @vicancy, yes what was noted in #1926 addressed my issue. A couple of things to be aware of:
also, having more debug information would be great in Azure SignalR Emulator, but while running that in debug mode locally and getting the error while debugging doesn't seem to yield any more details than the HttpClient Send error of, "An error occurred while sending the request." Would be great if your finds provides more debug details and would look forward to testing the latest version of Azure SignalR Emulator to determine what the actual error is, my guess is Azure SignalR connection cannot connect to my local running instance for the OnConnect/OnDisconnected handlers. Please keep me posted on the status of the latest build for ASE. Thanks |
Is your feature request related to a problem? Please describe.
I am trying to self-host an instance of Azure SignalR service for use with my Azure functions project. This would allow me to continue working on my project even when azure servers are down.
Describe the solution you'd like
A sample on how we could emulate or self-host azure signalR service would be great. I really want to be able to work on my Azure functions project without needing to connect to azure directly.
The text was updated successfully, but these errors were encountered: