I have a basic setup for Push Delivery, they are working fine without proxy. I tried to add a proxy setting but couldn't manage to make it work.
I am using below function to deliver push notifications:
Public Function Send(ByVal title As String, body As String, token As String) As String
Dim retval As String
Try
If FirebaseApp.DefaultInstance Is Nothing Then
Dim defaultApp = FirebaseApp.Create(New AppOptions() With {
.Credential = GoogleCredential.FromFile(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "key.json")), .HttpClientFactory = New ProxySupportedHttpClientFactory()
})
End If
Dim message As New Message
With message
.Webpush = New WebpushConfig
With message.Webpush
.Notification = New WebpushNotification
With message.Webpush.Notification
.Title = title
.Body = body
End With
End With
End With
Dim messaging = FirebaseMessaging.DefaultInstance
message.Token = token
Dim result = messaging.SendAsync(message)
retval = result.Result
Catch ex As Exception
retval = "ERROR: " & ex.Message
If Not ex.InnerException Is Nothing Then
If ex.InnerException.Message = "Requested entity was not found." Then
retval = "ERROR: Requested token is not registered or invalid."
Else
retval &= "INNER Exception: " & ex.InnerException.Message
End If
End If
End Try
Return retval
End Function
And using below class for proxy integration:
Public Class ProxySupportedHttpClientFactory
Inherits HttpClientFactory
Protected Overrides Function CreateHandler(ByVal args As CreateHttpClientArgs) As HttpMessageHandler
credentials = New NetworkCredential("1", "1")
Dim proxy = New WebProxy("http://127.0.0.1:8888", True, Nothing, credentials)
Dim webRequestHandler = New HttpClientHandler() With {
.UseProxy = True,
.Proxy = proxy,
.UseCookies = False
}
Return webRequestHandler
End Function
End Class
But when I try to send a notification I get "The remote server returned an error: (407) Proxy Authentication Required." error in line "retval = result.Result".
Proxy configuration is working fine with WebProxy with a simple request test but not with HttpClientHandler in FCM.
EDIT: I am using authorization with key.json file in credentials, articles says i should implement proxy for credential connectivity too but i couldn't find any way to integrate it with credential part.