简体   繁体   中英

Can't connect to Azure Notification Hub

I can't connect to Microsoft Azure Notification Hub to manage the subscriptions (get registrations and send notifications). I have a simple C# console tool and executing NotificationHubClient methods' the exception appears: (401) Not Allowed..TrackingId:****uid_here*****

With Fiddler, I got the following raw error message: HTTP/1.1 401 40103: Invalid authorization token signature

I'm using the Assembly Microsoft.Azure.NotificationHubs v2.16.0.0 with the correct connection string (full share access) and WindowsAzure.ServiceBus v4.0.0. I copied the exact connection string from the azure manage portal and I also tried to connect with the ServiceBusExplorer, but it was not possible and the with this tool I have the error:

Receivera:InternalServiceFault The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the <serviceDebug> configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework SDK documentation and inspect the server trace logs.

Anyone having this kind of trouble?

Tks!

UPDATED: Thank you guys. It was a connection string problem. The mistake was the SharedAccessKeyName. The current default name is DefaultFullSharedAccessSignature and my initial key RootManageSharedAccessKey doesn't work anymore. I think It could be changed by azure. It is not accepting connections with the root key... Or it was changed by someone else for other reason.

According to your description, I built my console application, installed Microsoft Azure Notification Hubs 1.0.7 and got connection string from the azure manage portal to test this issue. It could work as expected on my side, here is the code snippet, you could refer to it:

NotificationHubClient hub = NotificationHubClient.CreateClientFromConnectionString("{connection-string-with-full-access}", "{your-notification-hub-name}");
await hub.SendWindowsNativeNotificationAsync("{your-Windows-native-payload}");

For more details, you could follow this official document about sending push notifications from your back-end.

Your service bus connection string must include the Notification Hub name:

Endpoint=sb://my-notification-bus.servicebus.windows.net/;SharedAccessKeyName=DefaultFullSharedAccessSignature;SharedAccessKey=MySharedAccess; EntityPath=my-hub-name

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM