openimsdk / openim-docker

openim-docker configuration for deploying OpenIM. Provides a build solution for a stable distribution, as well as a docker compose deployment strategy
https://openim.io
Apache License 2.0
45 stars 56 forks source link

[DOC]: FCM using OpenIM server with Docker #194

Open buiphukhuyen opened 1 month ago

buiphukhuyen commented 1 month ago

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!

OpenIM-Robot commented 1 month ago

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.

skiffer-git commented 1 month ago

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

skiffer-git commented 1 month ago

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.

buiphukhuyen commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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
skiffer-git commented 1 month ago

In Docker, you should use the authURL field.

buiphukhuyen commented 1 month ago
  **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

skiffer-git commented 1 month ago

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

OpenIM-Robot commented 1 month ago

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


openim-server: (docker-compose.yaml)

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

It still not working!

skiffer-git commented 1 month ago

IMENV_OPENIM_PUSH_ENABLE=fcm

buiphukhuyen commented 1 month ago

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 commented 1 month ago

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 commented 3 weeks ago

Can anyone help me with this problem?

buiphukhuyen commented 4 days ago

Help me this issue!

Thanks @skiffer-git