Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No response from Firebase in Docker

I'm trying to query firebase from a node.js app in a Docker container. It works locally but not in the container. I have port 443 open and I can make a request to google fine. For some reason I never get a response back running in the Docker container though. I suspect it's something with websockets.

My Ports are: 0.0.0.0:443->443/tcp, 0.0.0.0:8080->8080/tcp

And in my docker syslog: : dropping unexpected TCP packet sent from 172.18.0.3:33288 to 216.58.210.173:443 (valid sources = 192.168.65.2, 0.0.0.0)

Any on ideas on what to try?

  firebase.initializeApp({
    serviceAccount: firebaseKey,
    databaseURL: 'https://my-firebase.firebaseio.com'
  });
  const userId = 'xxxxxxxxxxxx';
  const ref = firebase.database().ref(`datasource/${userId}`)
  .once('value').then( (snapshot) => {
    console.log(snapshot.val());
    return callback(null, 'ok');
  }, (error) => {
    console.error(error);
    return callback(error);
  });

And my docker-compose.yml

version: "2"

services:

    test-import:
      build: .
      command: npm run dev
      volumes:
        - .:/var/www
      ports:
       - "7000:8080"
       - "443:443"
      depends_on:
        - mongo
      networks:
        - import-net

    mongo:
      container_name: mongo
      image: mongo
      networks:
        - import-net

networks:
    import-net:
      driver: bridge
like image 746
jabbermonkey Avatar asked Jul 07 '16 18:07

jabbermonkey


1 Answers

In my case the problem was that serviceAccount.privateKey was set using an environment variable. The value of that environment variable is a multi line string and that was causing the issue. So double check that serviceAccount is correctly configured in order to solve this.

edit

I had the same problem again today. The solution was to sync the time with a NTP server because the time in the Docker container was wrong (a few days off).

like image 94
Korneel Avatar answered Oct 03 '22 23:10

Korneel