Skip to content

connectTimeout not working if network connection is not available. #317

@fahadshakeel1989

Description

@fahadshakeel1989

[READ] Step 1: Are you in the right place?

Yes

[REQUIRED] Step 2: Describe your environment

  • Operating System version: Linux
  • Firebase SDK version: 6.8.1
  • Library version: firebase-admin
  • Firebase Product: Push Notification

[REQUIRED] Step 3: Describe the problem

connectTimeout configured in FirebaseOptions object is not working if network connection is not available. Getting SocketTimeoutException once default http connect timeout occurs i.e. 60 seconds.

Steps to reproduce:

  1. Configure connectTimeout in FirebaseOptions object.
  2. Initialize FirebaseApp instance.
  3. Get FirebaseMessaging instance.
  4. Call send() method.

Relevant Code:

InetSocketAddress inetSocketAddress = new InetSocketAddress(proxy_ip, proxy_port);

HttpTransport httpTransport = new NetHttpTransport.Builder()
        .setProxy(new Proxy(Proxy.Type.HTTP, inetSocketAddress))
        .build();

HttpTransportFactory httpTransaportFactory = new HttpTransportFactory() {
        @Override
        public HttpTransport create() {
                return httpTransport
        }
};

GoogleCredentials googleCredentials = GoogleCredentials.fromStream(serviceAccount, httpTransaportFactory);

FirebaseOptions firebaseOptions = new FirebaseOptions.Builder()
        .setCredentials(googleCredentials)
        .setHttpTransport(httpTransport)
        .setConnectTimeout(2*1000)
        .setReadTimeout(3*1000)
        .build();

FirebaseApp firebaseApp = FirebaseApp.initializeApp(firebaseOptions);

FirebaseMessaging.getInstance(firebaseApp).send(message);

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions