[GH-ISSUE #240] Events Queue Setup & Configuration #27

Closed
opened 2026-03-03 16:36:02 +03:00 by kerem · 4 comments
Owner

Originally created by @bpcsys on GitHub (Jul 12, 2023).
Original GitHub issue: https://github.com/NdoleStudio/httpsms/issues/240

Hello am facing issues trying to set this up on my GCP, I enabled Google Cloud Tasks, also have the Firebase Admin Credentials.
But My Cloud Build Fails at the step of Cloud Tasks Client, I tried to at the logs but couldn't get any meaning full error.

{
    "pid": "1",
    "service.name": "*di.Container",
    "caller": "/http-sms/pkg/di/container.go:298",
    "error": "cannot initialize cloud tasks client\n --- at /http-sms/pkg/di/container.go:298 (Container.CloudTasksClient) ---\nCaused by: invalid character 'b' looking for beginning of value",
    "hostname": "localhost"
  }

I have also setup the environment variables.

EVENTS_QUEUE_TYPE=Push
EVENTS_QUEUE_USER_API_KEY=<here i used the one from the json crendetial got from firebase admin>
EVENTS_QUEUE_NAME=send-sms
EVENTS_QUEUE_USER_ID=<here i used the one from the json crendetial got from firebase admin>
EVENTS_QUEUE_ENDPOINT=projects/[PROJECT_ID]/locations/[LOCATION_ID]/queues/send-sms

Need your help. Thank You

Originally created by @bpcsys on GitHub (Jul 12, 2023). Original GitHub issue: https://github.com/NdoleStudio/httpsms/issues/240 Hello am facing issues trying to set this up on my GCP, I enabled Google Cloud Tasks, also have the Firebase Admin Credentials. But My Cloud Build Fails at the step of Cloud Tasks Client, I tried to at the logs but couldn't get any meaning full error. ```json { "pid": "1", "service.name": "*di.Container", "caller": "/http-sms/pkg/di/container.go:298", "error": "cannot initialize cloud tasks client\n --- at /http-sms/pkg/di/container.go:298 (Container.CloudTasksClient) ---\nCaused by: invalid character 'b' looking for beginning of value", "hostname": "localhost" } ``` I have also setup the environment variables. ```env EVENTS_QUEUE_TYPE=Push EVENTS_QUEUE_USER_API_KEY=<here i used the one from the json crendetial got from firebase admin> EVENTS_QUEUE_NAME=send-sms EVENTS_QUEUE_USER_ID=<here i used the one from the json crendetial got from firebase admin> EVENTS_QUEUE_ENDPOINT=projects/[PROJECT_ID]/locations/[LOCATION_ID]/queues/send-sms ``` Need your help. Thank You
kerem closed this issue 2026-03-03 16:36:02 +03:00
Author
Owner

@AchoArnold commented on GitHub (Jul 12, 2023):

Hello @bpcsys
Are you a Go programmer, if yes, look at how the queue is configured here https://github.com/NdoleStudio/httpsms/blob/main/api/pkg/di/container.go
I plan to improve the local setup instructions under #42 but I'm busy with other issues at the moment.

<!-- gh-comment-id:1632245405 --> @AchoArnold commented on GitHub (Jul 12, 2023): Hello @bpcsys Are you a Go programmer, if yes, look at how the queue is configured here https://github.com/NdoleStudio/httpsms/blob/main/api/pkg/di/container.go I plan to improve the local setup instructions under #42 but I'm busy with other issues at the moment.
Author
Owner

@bpcsys commented on GitHub (Jul 13, 2023):

Actually I am not a Go Programmer but thanks to your Well Documented code I was able to read and understand the code.
And here my main issue was that I wrongly set FIREBASE_CRENDENTIALS to a path instead of the actually JSON File.
Am Looking forward to learning go so that we can add more features to this. Thanks Alot!

<!-- gh-comment-id:1634023582 --> @bpcsys commented on GitHub (Jul 13, 2023): Actually I am not a Go Programmer but thanks to your Well Documented code I was able to read and understand the code. And here my main issue was that I wrongly set `FIREBASE_CRENDENTIALS` to a path instead of the actually `JSON` File. Am Looking forward to learning go so that we can add more features to this. Thanks Alot!
Author
Owner

@bpcsys commented on GitHub (Jul 15, 2023):

@AchoArnold If you happen to have time just help me find out what am doing wrong after setting up everything. I came to this issue that appeared when I Tried to send the message.

{
caller: "/http-sms/pkg/handlers/message_handler.go:99"
pid: "1"
hostname: "localhost"
error: "cannot send message with paylod [{"to":"+256761585999","from":"+256784007449","content":"Just a Test Message","sim":"DEFAULT"}]
 --- at /http-sms/pkg/handlers/message_handler.go:99 (MessageHandler.PostSend) ---
Caused by: cannot dispatch event type [message.api.sent] and id [37b8c7cb-dde6-4d6b-8c9d-3463e3d0bdd2]
 --- at /http-sms/pkg/services/message_service.go:336 (MessageService.SendMessage) ---
Caused by: cannot enqueue event with ID [37b8c7cb-dde6-4d6b-8c9d-3463e3d0bdd2] and type [message.api.sent]
 --- at /http-sms/pkg/services/event_dispatcher_service.go:83 (EventDispatcher.DispatchWithTimeout) ---
Caused by: cannot schedule task {"specversion":"1.0","id":"37b8c7cb-dde6-4d6b-8c9d-3463e3d0bdd2","source":"/v1/messages/send","type":"message.api.sent","datacontenttype":"application/json","time":"2023-07-15T06:51:20.945343849Z","data":{"message_id":"a3029903-e144-455f-ad92-d891a0b7ef6c","user_id":"3UpI85bZaHXa1tXOiSR8YdFJ9783","owner":"+256784007449","max_send_attempts":2,"contact":"+256761585999","request_received_at":"2023-07-15T06:51:20.914974782Z","content":"Just a Test Message","sim":"SIM1"}} to URL: projects/bpc-management-system/locations/us-central1/queues/send-sms
 --- at /http-sms/pkg/services/google_cloud_push_queue_service.go:73 (googlePushQueue.Enqueue) ---
Caused by: rpc error: code = PermissionDenied desc = Cloud Tasks API has not been used in project 25699032575 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/cloudtasks.googleapis.com/overview?project=25699032575 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.
error details: name = ErrorInfo reason = SERVICE_DISABLED domain = googleapis.com metadata = map[consumer:projects/25699032575 service:cloudtasks.googleapis.com]
error details: name = Help desc = Google developers console API activation url = https://console.developers.google.com/apis/api/cloudtasks.googleapis.com/overview?project=25699032575"
service.name: "*handlers.MessageHandler"
}

I the PROJECT_ID set to my project ID and When I read the log I see another PROJECT_ID 25699032575 which seems to be an internal googl project id.
Am wondering where it comes from.

<!-- gh-comment-id:1636705362 --> @bpcsys commented on GitHub (Jul 15, 2023): @AchoArnold If you happen to have time just help me find out what am doing wrong after setting up everything. I came to this issue that appeared when I Tried to send the message. ``` { caller: "/http-sms/pkg/handlers/message_handler.go:99" pid: "1" hostname: "localhost" error: "cannot send message with paylod [{"to":"+256761585999","from":"+256784007449","content":"Just a Test Message","sim":"DEFAULT"}] --- at /http-sms/pkg/handlers/message_handler.go:99 (MessageHandler.PostSend) --- Caused by: cannot dispatch event type [message.api.sent] and id [37b8c7cb-dde6-4d6b-8c9d-3463e3d0bdd2] --- at /http-sms/pkg/services/message_service.go:336 (MessageService.SendMessage) --- Caused by: cannot enqueue event with ID [37b8c7cb-dde6-4d6b-8c9d-3463e3d0bdd2] and type [message.api.sent] --- at /http-sms/pkg/services/event_dispatcher_service.go:83 (EventDispatcher.DispatchWithTimeout) --- Caused by: cannot schedule task {"specversion":"1.0","id":"37b8c7cb-dde6-4d6b-8c9d-3463e3d0bdd2","source":"/v1/messages/send","type":"message.api.sent","datacontenttype":"application/json","time":"2023-07-15T06:51:20.945343849Z","data":{"message_id":"a3029903-e144-455f-ad92-d891a0b7ef6c","user_id":"3UpI85bZaHXa1tXOiSR8YdFJ9783","owner":"+256784007449","max_send_attempts":2,"contact":"+256761585999","request_received_at":"2023-07-15T06:51:20.914974782Z","content":"Just a Test Message","sim":"SIM1"}} to URL: projects/bpc-management-system/locations/us-central1/queues/send-sms --- at /http-sms/pkg/services/google_cloud_push_queue_service.go:73 (googlePushQueue.Enqueue) --- Caused by: rpc error: code = PermissionDenied desc = Cloud Tasks API has not been used in project 25699032575 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/cloudtasks.googleapis.com/overview?project=25699032575 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry. error details: name = ErrorInfo reason = SERVICE_DISABLED domain = googleapis.com metadata = map[consumer:projects/25699032575 service:cloudtasks.googleapis.com] error details: name = Help desc = Google developers console API activation url = https://console.developers.google.com/apis/api/cloudtasks.googleapis.com/overview?project=25699032575" service.name: "*handlers.MessageHandler" } ``` I the PROJECT_ID set to my project ID and When I read the log I see another PROJECT_ID `25699032575` which seems to be an internal googl project id. Am wondering where it comes from.
Author
Owner

@AchoArnold commented on GitHub (Jul 23, 2023):

@bpcsys see the comment on #249

<!-- gh-comment-id:1646767765 --> @AchoArnold commented on GitHub (Jul 23, 2023): @bpcsys see the comment on #249
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/httpsms#27
No description provided.