Comments (5)
@tiaan-lg yes, that would be a recommended approach. Please reopen this issue if this is still a problem.
from azure-notificationhubs-dotnet.
For anybody struggling with this, we solved it by passing in a MessageHandler from the
IHttpMessageHandlerFactory this prevents it from recreating the HTTP client and starving sockets
Example code where _httpMessageHandler is a static property
// if handler is not created, then create it
if (_httpMessageHandler == null)
{
var serviceProvider = new ServiceCollection().AddHttpClient().BuildServiceProvider();
var httpClientFactory = serviceProvider.GetService<IHttpMessageHandlerFactory>();
_httpMessageHandler = httpClientFactory.CreateHandler();
}
var hub = new NotificationHubClient({{Connection String}}, {{Hub Path}}, new NotificationHubClientSettings
{
MessageHandler = _httpMessageHandler
});
from azure-notificationhubs-dotnet.
I am also experiencing issues with using the hub client whereby it is exhausting sockets, what is the best practice for creating the and reusing the NotificationHubClient
from azure-notificationhubs-dotnet.
@mpodwysocki Can you please clarify if this approach is correct or not, we are adding the following code in the Constructor of our Controller.
private NotificationHubClient _nhClient;
public NotificationsController(CMLogger logger,
IConfiguration config, IHttpMessageHandlerFactory httpMessageHandler)
{
_logger = logger;
_config = config;
_nhClient = new NotificationHubClient(_config["NotificationsHub:ConnectionString"],
_config["NotificationsHub:HubName"],
new NotificationHubClientSettings
{
OperationTimeout = TimeSpan.FromSeconds(10),
MessageHandler = httpMessageHandler.CreateHandler()
})
}
from azure-notificationhubs-dotnet.
Example code where _httpMessageHandler is a static property
Wouldn't this static HttpMessageHandler
result in an also static HttpClientHandler
for the whole lifetime of the application and therefore, might cause issues with DNS changes?
If I understand the inner workings of DefaultHttpClientFactory
(which implements IHttpMessageHandlerFactory
) correctly, calling CreateHandler()
everytime a NotificationHubClient
with scoped lifetime is created, should reuse the same handler pipeline. At least withing the lifetime of ActiveHandlerTrackingEntry
. This reusing should mitigate the problem of socket exhaustion.
Please correct me if I understood something wrong.
from azure-notificationhubs-dotnet.
Related Issues (20)
- [FEATURE REQ] Update Firebase Messaging to stop using old FCM APIs HOT 1
- Firebase Legacy HTTP Send API are to be decommissioned after June 20, 2024 HOT 2
- [BUG] NotificationHubClient.GetRegistrationsByChannelAsync not returning any result on IOS
- [BUG] Azure notification hub doesn't accept token format from firebase_messaging
- [BUG] Notifications continue to send after deleting an installation HOT 2
- [Question] Azure Notification Hub on MAUI HOT 25
- [BUG] MessagingEntityNotFoundException when getting notification outcome details
- The Push Notification System handle for the registration is invalid
- Option to connect by Managed Identity
- Links routes to page: content not found (404)
- Why is the notification hub client missing BrowserNotification support?
- [BUG] 4.2.0 adds support for FCM v1...but no way to call SendFcmv1NativeNotificationAsync since it's missing from the INotificationHubClient interface HOT 2
- Issue: Lack of Support for FCMv1 Credentials in Microsoft.NotificationHubs ARM/Bicep Template HOT 1
- [FEATURE REQ] Update out-of-date samples
- [BUG] template notification not working with FCMv1 HOT 2
- [FEATURE REQ] Add support for Browser (Web Push) HOT 4
- [BUG] Provide new nuget packages, and docs with examples that will show how to use Azure Notification Hubs with MAUI HOT 1
- [BUG] Microsoft.Azure.NotificationHubs Version=4.2.0 HOT 3
- [QUERY] Will the SendDirectNotificationAsync method still work with the internal shift to FCM v1 ?
- [BUG] Notifications Sent to All Devices Instead of Targeted Device with FcmV1 Installation in Azure Notification Hubs 4.2.0 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from azure-notificationhubs-dotnet.