firebase / firebase-admin-dotnet

Firebase Admin .NET SDK
https://firebase.google.com/docs/admin/setup
Apache License 2.0
367 stars 131 forks source link

Issue to Reach FireBase API #254

Closed skogkatt closed 3 years ago

skogkatt commented 3 years ago

Hello all,

As already mentionned, this is the sample code i use to contact firebase with the method to susbscribe a Topic :

        FirebaseApp defaultapp = null;
        FirebaseAdmin.Messaging.FirebaseMessaging messaging = null;

        // Initialize the default app
        string path = AppDomain.CurrentDomain.BaseDirectory + "a2s-production-firebase-adminsdk-.json";

            defaultapp = FirebaseApp.Create(new AppOptions()
            {
                Credential = GoogleCredential.FromFile(path),
            });

        messaging = FirebaseAdmin.Messaging.FirebaseMessaging.GetMessaging(defaultapp);

        var response = await messaging.SubscribeToTopicAsync(registrationTokens,topic);

when i try to call this code from API i get a socket exception "StatusCode": 50000, "TechnicalMessage": "System.Net.Sockets.SocketException (0x80004005): Une tentative de connexion a échoué car le parti connecté n’a pas répondu convenablement au-delà d’une certaine durée ou une connexion établie a échoué car l’hôte de connexion n’a pas répondu à System.Net.Sockets.Socket.InternalEndConnect(IAsyncResult asyncResult)\r\n à System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)\r\n à System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)", "UserFriendlyMessage": null

It works when :

1- i'm getting out of the work network and plug myself in 4g hotspot it works. Is That have to do with the local network or try to access to a specific url ?

2 - i call this code from a console application.

Thanks for the help in advance.

hiranya911 commented 3 years ago

Is That have to do with the local network or try to access to a specific url ?

Most of the time when the issue only occurs on a certain network, it's because the network uses specific Firewall or proxy settings. You will need to check if such requirements exist in your work network, and handle them accordingly.

skogkatt commented 3 years ago

in out network there's a limitation so i asked to open those urls : https://oauth2.googleapis.com https://fcm.googleapis.com

i configured the proxy on the server for me to access those urls. Firewall are disabled.

hiranya911 commented 3 years ago

Typically you would configure the SDK to make API calls through the proxy. This is done by extending the HttpClientFactory. See #209.