Closed Faisal0sal closed 4 years ago
Hi!
.NET Core apps can consume .NET Framework library, albeit their functionality may be limited when used like that.
In our case, however, the required functionality works as expected, so you may safely ignore the warning. It shouldn't prevent you from building and running your application.
@alexalok Thank you for your response, I was going to use as you said anyway. But I'm trying to add services.AddApns();
And it says that there is no reference for it.
It seems that you've referenced the main dotAPNS package. Instead, you should reference dotAPNS.AspNetCore package, which contains code that integrates dotAPNS with ASP.NET Core projects.
Also, if you reference dotAPNS.AspNetCore, you can safely remove the reference to dotAPNS as it is implicitly added to the project anyway.
Thank you so much. One more thing, when using the certificate we do need to specify the password. How would we do that after CreateUsingCert
I have created another certificate with no password, then faced this issue:
An error occurred while sending the request. ---> System.ObjectDisposedException: Cannot access a disposed object. Object name: 'SslStream'.
Please provide a code sample that you have issues with. Note that ApnsClient.CreateUsingCert
has an overload allowing you to pass X509Certificate2
object, which you can construct from an arbitrary certificate, even the one that has a password (see this for reference).
Well, I have been able to work with the certificate issue. Only this issue is now I'm facing:
An error occurred while sending the request. ---> System.ObjectDisposedException: Cannot access a disposed object. Object name: 'SslStream'.
`// POST
// Send Notifications
// KeyId {}
[HttpPost("notify")]
public async Task
ApnsResponse response = await ApnsService.SendPush(push, cert);
return Json(ApiResponse.GetResponse(HttpContext, 200));
}`
I see. Could you please provide a full stack trace of an exception? Right now I'm not entirely sure as to what can be the cause of the issue you're facing.
System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.ObjectDisposedException: Cannot access a disposed object. Object name: 'SslStream'. at System.Net.Security.SslStream.ThrowIfExceptional() at System.Net.Security.SslStream.CheckThrow(Boolean authSuccessCheck, Boolean shutdownCheck) at System.Net.Security.SslStream.ReadAsync(Memory
1 buffer, CancellationToken cancellationToken)
at System.Net.Http.Http2Connection.ReadAtLeastAsync(Stream stream, Memory1 buffer, Int32 minReadBytes) at System.Net.Http.Http2Connection.EnsureIncomingBytesAsync(Int32 minReadBytes) at System.Net.Http.Http2Connection.ReadFrameAsync(Boolean initialFrame) at System.Net.Http.Http2Connection.ProcessIncomingFramesAsync() --- End of inner exception stack trace --- at System.Net.Http.Http2Connection.SendHeadersAsync(HttpRequestMessage request, CancellationToken cancellationToken, Boolean mustFlush) at System.Net.Http.Http2Connection.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken) at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) at System.Net.Http.DiagnosticsHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task
1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
at dotAPNS.ApnsClient.Send(ApplePush push)
at WalaaWalletPass.Controllers.PassHandler.sendNotificationAsync() in /Users/fmalsalamah/Projects/wallet-pass-db/CreativeTim.Argon.DotNetCore.Free/Controllers/PassHandler.cs:line 111
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.
Issue is not happening anymore once I have set sandbox to true
According to the stack trace, I can see that the actual exception happens somewhere inside the HttpClient that dotAPNS uses to make HTTP/2 requests. Unfortunately, there is no clear sign of what can be causing the issue.
If possible, create a separate project with the minimum code that reproduces the issue and send it to me at contact@alexalok.me If you do so, please be sure to include the certificate you are using as well, as I do not have any .p12 certificates to test with. I will make sure to delete it after we resolve the issue.
Another option would be to switch to a token-based connection. If you have the proper rights in the Apple Developer Account, I highly suggest to do so as the certificate-based HTTP/2 connection support overall seems to be quite quirky in .NET (see #3, #4).
Hi, @Faisal0sal, just checking if you still need an assistance. If you're all up and running, perhaps the issue can be closed? Please note that if there is no answer from your side the issue will be closed in a few days.
The issue is closed due to the lack of feedback.
Warning NU1701: Package 'BouncyCastle 1.8.5' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework '.NETCoreApp,Version=v3.1'. This package may not be fully compatible with your project. (NU1701)