openimsdk / helm-charts

helm charts repository for openim
https://openimsdk.github.io/helm-charts/
Apache License 2.0
14 stars 9 forks source link

Bug: unable to use fcm push #27

Closed Sylariam closed 7 months ago

Sylariam commented 7 months ago

What happened?

I am trying to explore the Push feature of the OpenIM server(using android demo app). I noticed that the configuration options include FCM. However, the documentation on how to use FCM is somewhat unclear. config: image The format for push.fcm.serviceAccount is "x.json," so I assume this should be a JSON file. Initially, I placed the JSON file in the root directory of the Helm charts. It DID NOT work. I replaced the Helm image repository with my own packaged image and added some logs during startup. The logs indicate that the push service did not correctly read push.fcm.serviceAccount. Then I realized that helm did not specify serviceAccount during the Helm install. Certainly, there isn't that file inside the container either. So, how should I fix it?

What did you expect to happen?

The FCM client initialized properly, and offline push notifications could be sent.

How can we reproduce it (as minimally and precisely as possible)?

in config-imserver.yaml, change push.enable to fcm

Anything else we need to know?

No response

version

```console $ {name} version # paste output here ```

Cloud provider

aliyun

OS version

```console # On Linux: $ cat /etc/os-release # paste output here $ uname -a # paste output here # On Windows: C:\> wmic os get Caption, Version, BuildNumber, OSArchitecture # paste output here ```

Install tools

cubxxw commented 7 months ago

Hi @Sylariam,

Thank you for reaching out to us regarding the issue you encountered with OpenIM's FCM push feature.

Based on your description, it seems that the push service did not correctly read push.fcm.serviceAccount, and you realized that helm did not specify serviceAccount during the Helm install.

To fix this issue, you can try the following steps:

  1. Create a Kubernetes secret using your FCM service account JSON file:
    kubectl create secret generic fcm-secret --from-file=serviceAccount.json=<path/to/your/serviceAccount.json>
  2. In your config-imserver.yaml, specify the push.fcm.serviceAccount as the path to your FCM service account JSON file inside the container:
    push:
    enable: fcm
    fcm:
    serviceAccount: /path/to/serviceAccount.json
  3. When installing Helm, specify the --set serviceAccount.create=true flag to create a service account for your Helm chart:
    helm install my-openim-chart openim-chart --set serviceAccount.create=true

Please let us know if this solution works for you. If you have any further questions, feel free to ask.

Sylariam commented 7 months ago

I don't think this has anything to do with k8s service account... or has it?

Sylariam commented 7 months ago

Perhaps I didn't clarify the issue. After installing with Helm, the Push service fails to correctly load the FCM service account configuration when creating the client. In line 44: image So I figured there might be a misstep with push.fcm.serviceAccount?

Sylariam commented 7 months ago

I don't think this has anything to do with k8s service account... or has it?

Due to the presence of config-imserver.yaml, I assumed that specifying a similar method during helm install to use a configuration file would be sufficient. Why go through the extensive process of using Kubernetes secrets and service accounts?