openim-docker icon indicating copy to clipboard operation
openim-docker copied to clipboard

[DOC]: FCM using OpenIM server with Docker

Open buiphukhuyen opened this issue 1 year ago β€’ 15 comments

Hi team,

I’m using OpenIM server with Docker and would like to integrate Firebase Cloud Messaging (FCM) for push notifications. I’ve mapped the Firebase JSON file into the container, but I’m unsure of the next steps. Could you guide me on how to configure FCM within the OpenIM server?

Thank you!

buiphukhuyen avatar Oct 18 '24 06:10 buiphukhuyen

Hello! Thank you for filing an issue.

If this is a bug report, please include relevant logs to help us debug the problem.

Join slack πŸ€– to connect and communicate with our developers.

OpenIM-Robot avatar Oct 18 '24 06:10 OpenIM-Robot

https://github.com/openimsdk/openim-docker/issues/136

skiffer-git avatar Oct 18 '24 07:10 skiffer-git

Here's how you can set the relevant environment variables based on the file referenced from the link:

First, locate the corresponding configuration items in the file. Then, follow the provided rules to set the environment variables appropriately.

skiffer-git avatar Oct 18 '24 07:10 skiffer-git

Thank you!

Can you give me the document on how to test FCM function? Because I don't know where it is to test!

buiphukhuyen avatar Oct 18 '24 08:10 buiphukhuyen

I edited docker-compose.yaml with:

openim-server:
    image: ${OPENIM_SERVER_IMAGE}
    container_name: openim-server
    init: true
    ports:
      - "${OPENIM_MSG_GATEWAY_PORT}:10001"
      - "${OPENIM_API_PORT}:10002"
    healthcheck:
      test: [ "CMD", "sh", "-c", "mage check" ]
      interval: 5s
      timeout: 60s
      retries: 10
    environment:
      - IMENV_MONGODB_ADDRESS=${MONGO_ADDRESS}
      - IMENV_MONGODB_USERNAME=${MONGO_USERNAME}
      - IMENV_MONGODB_PASSWORD=${MONGO_PASSWORD}
      - IMENV_KAFKA_ADDRESS=${KAFKA_ADDRESS}
      - IMENV_DISCOVERY_ETCD_ADDRESS=${ETCD_ADDRESS}
      - IMENV_REDIS_ADDRESS=${REDIS_ADDRESS}
      - IMENV_REDIS_PASSWORD=${REDIS_PASSWORD}
      - IMENV_MINIO_INTERNALADDRESS=${MINIO_INTERNAL_ADDRESS}
      - IMENV_MINIO_EXTERNALADDRESS=${MINIO_EXTERNAL_ADDRESS}
      - IMENV_MINIO_ACCESSKEYID=${MINIO_ACCESS_KEY_ID}
      - IMENV_MINIO_SECRETACCESSKEY=${MINIO_SECRET_ACCESS_KEY}
      - IMENV_SHARE_SECRET=${OPENIM_SECRET}
      - IMENV_LOG_ISSTDOUT=${LOG_IS_STDOUT}
      - IMENV_LOG_REMAINLOGLEVEL=${LOG_LEVEL}
      - IMENV_OPENIM_API_PROMETHEUS_GRAFANAURL=${GRAFANA_URL}
      **- IMENV_OPENIM_PUSH_ENABLE=FCM
      - IMENV_OPENIM_PUSH_FCM_FILEPATH=${FCM_FILE_PATH}**
    restart: always
    networks:
      - openim

And .env FCM_FILE_PATH=./config/it-hutech-firebase-adminsdk-gvile-ee4bba1b64.json

But when I send a message and check on FCM, I don't see the report.

Screenshot 2024-10-18 at 15 15 18

I looked at the logs with the command "docker logs -f openim-server" but didn't see any errors!

buiphukhuyen avatar Oct 18 '24 08:10 buiphukhuyen

I have configured on flutter sdk to update FCM token to Server. And the server has recorded this Token (in redis). However, when I test, I don't see any notification and I don't know how to see if it is successful or not! Screenshot 2024-10-18 at 17 19 34

buiphukhuyen avatar Oct 18 '24 10:10 buiphukhuyen

In Docker, you should use the authURL field.

skiffer-git avatar Oct 22 '24 08:10 skiffer-git

  **I have configured docker-compose.yaml as follows:**
  - IMENV_OPENIM_PUSH_ENABLE=FCM
  - IMENV_OPENIM_PUSH_FCM_AUTHURL=${FCM_FILE_PATH}
  
 **.env**
  FCM_FILE_PATH="http://157.20.82.3/config/it-hutech-firebase-adminsdk-gvile-ee4bba1b64.json"

Then I tried sending offline message but fcm still not push notification like filepath configuration

buiphukhuyen avatar Oct 23 '24 08:10 buiphukhuyen

Instead of using the filePath field, you should use the authURL field.

skiffer-git avatar Oct 24 '24 04:10 skiffer-git

Bot detected the issue body's language is not English, translate it automatically. πŸ‘―πŸ‘­πŸ»πŸ§‘β€πŸ€β€πŸ§‘πŸ‘«πŸ§‘πŸΏβ€πŸ€β€πŸ§‘πŸ»πŸ‘©πŸΎβ€πŸ€β€πŸ‘¨πŸΏπŸ‘¬πŸΏ


openim-server: (docker-compose.yaml)

  • IMENV_OPENIM_PUSH_ENABLE=FCM
  • IMENV_OPENIM_PUSH_FCM_AUTHURL=${FCM_AUTHURL}

.env FCM_AUTHURL="http://157.20.82.3/config/it-hutech-firebase-adminsdk-gvile-ee4bba1b64.json"

It still not working!

OpenIM-Robot avatar Oct 24 '24 04:10 OpenIM-Robot

IMENV_OPENIM_PUSH_ENABLE=fcm

skiffer-git avatar Oct 24 '24 06:10 skiffer-git

Thank you. When I change the value back to "fcm" and run docker again, sending offline message fails:

[push/push_handler.go:178] offlinePushMsg failed {"platform": "Web", "connID": "10b7c6222bed325b18d57e7996bd275c", "operationID": "3bba685b-e953-49de-88ba-4df28e96bc6f", "opUserID": "1113466438", "offlinePushUserID": ["2604"], "msg": "sendID:\"1113466438\" recvID:\"2604\" clientMsgID:\"a31286fd8e6d78c24c35e00301544824\" serverMsgID:\"ae85d38e13e17e1f99526e3e7f9b39cd\" senderPlatformID:5 senderNickname:\"khuyenpb\" sessionType:1 msgFrom:100 contentType:101 content:\"{\\\"content\\\":\\\"FA\\\"}\" seq:203 sendTime:1729753131857 createTime:1729753117294 status:1 offlinePushInfo:{title:\"You have a new message.\" iOSPushSound:\"+1\" iOSBadgeCount:true} attachedInfo:\"null\"", "error": "1 message send failed;send err:;message err:"}

I don't know how to configure or fix the next error!

buiphukhuyen avatar Oct 24 '24 07:10 buiphukhuyen

I have referred to an article that is similar to mine but I don't know how this person fixed it!

https://github.com/openimsdk/open-im-server/issues/2572

buiphukhuyen avatar Oct 24 '24 07:10 buiphukhuyen

Can anyone help me with this problem?

buiphukhuyen avatar Nov 01 '24 17:11 buiphukhuyen

Help me this issue!

Thanks @skiffer-git

buiphukhuyen avatar Nov 21 '24 23:11 buiphukhuyen