Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Push notification messages not delivered to iPhone/Android phones #120

Closed
jeydude1 opened this issue Feb 18, 2021 · 48 comments
Closed

Push notification messages not delivered to iPhone/Android phones #120

jeydude1 opened this issue Feb 18, 2021 · 48 comments
Assignees
Labels
backend LAMP-server, LAMP-worker, and LAMP-app-gateway bug Something isn't working NO ETA No "days of effort required" assigned yet

Comments

@jeydude1
Copy link

jeydude1 commented Feb 18, 2021

Hello,

We are not getting push notification messages to iPhone device, I have attached our LAMP YAML configuration and log from API Server. while looking at the log, I have noticed Push gateway address is not defined message in the API Server log. Is there anything I have to do.

While looking at the previous git issue - #88, user says, he enabled toggle button on the Dashboard app. I do not see any Toggle button.

image

Here is the lamp configuration

version: '3.7'
services:
  server:
    image: bidmcdigitalpsychiatry/lamp-server:2021
    healthcheck:
      test: wget --no-verbose --tries=1 --spider http://localhost:3000 || exit 1
    environment:
      HTTPS: 'off'
      SCHEDULER: 'on'
      ROOT_KEY: ''
      CDB: ''
      PUSH_API_GATEWAY: 'app-gateway.lamp.digital'
      PUSH_API_KEY: ''
      DASHBOARD_URL: 'dashboard.lamp.digital'
      REDIS_HOST: 'redis://cache:6379/0'
      NATS_SERVER: 'message_queue:4222'
    networks:
      - default
      - public
    deploy:
      mode: replicated
      update_config:
        order: start-first
        failure_action: rollback
      labels:
         traefik.enable: 'true'
         traefik.http.routers.lamp_server.entryPoints: 'websecure'
         traefik.http.routers.lamp_server.rule: 'Host(`APIHOSTNAME`)'
         traefik.http.routers.lamp_server.tls.certresolver: 'default'
         traefik.http.services.lamp_server.loadbalancer.server.port: 3000
         traefik.docker.network: 'public'
      placement:
        constraints:
          - node.role == manager 
  database:
    image: mlpcouchdb
    healthcheck:
      test: curl --fail --silent http://localhost:5984/_up || exit 1
    environment:
      COUCHDB_USER: 'admin'
      COUCHDB_PASSWORD: 'YOURPASSWORD'
    volumes:
      - /apps/mindLAMP/data/couchdb:/opt/couchdb/data
    networks:
      - public
    deploy:
      mode: replicated
      update_config:
        order: stop-first
        failure_action: rollback
      placement:
        constraints:
          - node.role == manager
    ports:
    - "4369:4369/tcp"
    - "5984:5984/tcp"
    - "9100:9100/tcp"
    labels:
      traefik.enable: 'true'
      traefik.http.routers.lamp_database.entryPoints: 'websecure'
      traefik.http.routers.lamp_database.rule: 'Host(`DBHOSTNAME`)'
      traefik.http.routers.lamp_database.tls.certresolver: 'default'
      traefik.http.services.lamp_database.loadbalancer.server.port: 5984
  cache:
    image: redis:6.0.8-alpine
    healthcheck:
      test: redis-cli ping
    deploy:
      mode: replicated
      update_config:
        order: stop-first
        failure_action: rollback
      placement:
        constraints:
          - node.role == manager
  message_queue:
    image: nats:2.1.9-alpine3.12
    healthcheck:
      test: wget --no-verbose --tries=1 --spider http://localhost:8222/varz || exit 1
    deploy:
      mode: replicated
      update_config:
        order: start-first
        failure_action: rollback
      placement:
        constraints:
          - node.role == manager
networks:
  public:
    external: true

Here is the server log:

2021-02-18T15:03:04.686601703Z Initializing LAMP API server...
2021-02-18T15:03:04.689905270Z   Initializing database connection...
2021-02-18T15:03:04.721121732Z     Connected to Nats Pub Server
2021-02-18T15:03:04.721353806Z     Connected to Nats Sub Server
2021-02-18T15:03:04.813642701Z     ActivitySpec database online.
2021-02-18T15:03:04.813659640Z     SensorSpec database online.
2021-02-18T15:03:04.813663183Z     Researcher database online.
2021-02-18T15:03:04.813666910Z     Study database online.
2021-02-18T15:03:04.813669836Z     Participant database online.
2021-02-18T15:03:04.813672810Z     Activity database online.
2021-02-18T15:03:04.813749771Z     Sensor database online.
2021-02-18T15:03:04.813786780Z     ActivityEvent database online.
2021-02-18T15:03:04.813797887Z     SensorEvent database online.
2021-02-18T15:03:04.813806785Z     Credential database online.
2021-02-18T15:03:04.813815554Z     Tag database online.
2021-02-18T15:03:04.813825847Z   Database verification complete.
2021-02-18T15:03:04.814365505Z   Server routing initialized.
2021-02-18T15:03:04.814374607Z   Clean all queues...
2021-02-18T15:03:04.814849497Z   CLEANING ALL QUEUE
2021-02-18T15:03:04.821526163Z   DONE--CLEANING ALL QUEUE
2021-02-18T15:03:04.821558347Z   Initializing schedulers...
2021-02-18T15:03:04.823768472Z Initialization complete.
2021-02-18T15:03:05.085939635Z activity_id given undefined
2021-02-18T15:03:05.085967540Z Saving to redis
2021-02-18T15:03:05.085992961Z Processing 29 activities for push notifications.
2021-02-18T15:03:05.086912817Z locked job on activity_scheduler
2021-02-18T15:03:05.088241734Z actvityId wqcszngqgawy6exm35h2
2021-02-18T15:03:05.173035265Z participantslength 3
2021-02-18T15:03:05.431277149Z actvityId xgkpc0q2wb9jk06cfdxf
2021-02-18T15:03:05.431493748Z actvityId f8emztwhnxqeyrak835b
2021-02-18T15:03:05.431703030Z actvityId h2x1sm5y4hrys6p321df
2021-02-18T15:03:05.431890020Z actvityId 26szk8cttcbsv9ngnec5
2021-02-18T15:03:05.432101554Z actvityId qw774h2mm2e5j88cg58d
2021-02-18T15:03:05.432288038Z actvityId cq3b1p6pqgrtzkdpt416
2021-02-18T15:03:05.432478169Z actvityId kgpvyzbj098zyevz78bv
2021-02-18T15:03:05.432640567Z actvityId 2vhcsxak8v88vj8t0rcb
2021-02-18T15:03:05.432818447Z actvityId 6pzj92q6ccaw8741wsts
2021-02-18T15:03:05.432980342Z actvityId t9ghgn8hn91c34wtp606
2021-02-18T15:03:05.433141907Z actvityId gmr8jv48ce8ve7mkdbsd
2021-02-18T15:03:05.433334848Z actvityId 8amhwenggvx013w37vy5
2021-02-18T15:03:05.433506161Z actvityId mk8bfw38sghm7ng92fkc
2021-02-18T15:03:05.433682717Z actvityId xdcbckh2bzb0tjrm9k33
2021-02-18T15:03:05.433836014Z actvityId xw07pgy2257a8m0dd4h5
2021-02-18T15:03:05.434003005Z actvityId s9wjamynp0kyfd9fef29
2021-02-18T15:03:05.434165801Z actvityId 4gjfjbjpekjnyce41cqa
2021-02-18T15:03:05.434342285Z actvityId bfx54bdsf6fgp7kfdyrs
2021-02-18T15:03:05.480890693Z participantslength 1
2021-02-18T15:03:05.513373074Z actvityId 472cf23t24eb32yj0nbx
2021-02-18T15:03:05.557966954Z participantslength 1
2021-02-18T15:03:05.598801226Z actvityId 7zfymq54wncnzstk2f53
2021-02-18T15:03:05.640859442Z participantslength 2
2021-02-18T15:03:05.661889136Z actvityId 6w6ejdmjxhzs2wm6b5bp
2021-02-18T15:03:05.662058427Z actvityId y8rksht24gsjdf43aydt
2021-02-18T15:03:05.662247047Z actvityId a1sfhvgppr2m593qhsj0
2021-02-18T15:03:05.706131371Z participantslength 1
2021-02-18T15:03:05.736757745Z actvityId khp9tv894k2ew5fg3ydb
2021-02-18T15:03:05.780249171Z participantslength 1
2021-02-18T15:03:05.809019483Z actvityId 46m9vtdwdzc5sdxm5b49
2021-02-18T15:03:05.850266434Z participantslength 3
2021-02-18T15:03:06.086435844Z actvityId 67vgt8869j6rm3saqewh
2021-02-18T15:03:06.086657235Z actvityId msv3g9p4n3by8fk77tds
2021-02-18T15:03:06.086832905Z actvityId 6h1d9as9jz6c7acayhm1
2021-02-18T15:03:06.086845311Z Saving to Redis completed....
2021-02-18T15:03:06.086952124Z release lock  on success  activity_scheduler

.....
.....


2021-02-18T20:09:23.380400713Z POST /participant/U5146082234/sensor_event 200 - 1384.353 ms
2021-02-18T20:09:26.561929672Z POST /participant/U5146082234/sensor_event 200 - 1213.633 ms
2021-02-18T20:09:43.064681708Z GET / 200 - 5.568 ms

021-02-18T20:10:00.020998643Z {
2021-02-18T20:10:00.021039703Z   device_token: '91e78f48e9d16e13fcdba7bacfb72b0117eb01d52f44b6022e3cf448c6b13021',
2021-02-18T20:10:00.021044035Z   device_type: 'ios',
2021-02-18T20:10:00.021047357Z   payload: {
2021-02-18T20:10:00.021050378Z     participant_id: 'U2932822766',
2021-02-18T20:10:00.021053490Z     activity_id: '46m9vtdwdzc5sdxm5b49',
2021-02-18T20:10:00.021056775Z     message: 'You have a mindLAMP activity waiting for you: DBT Diary Card.',
2021-02-18T20:10:00.021059772Z     title: 'DBT Diary Card',
2021-02-18T20:10:00.021062690Z     url: '/participant/U2932822766/activity/46m9vtdwdzc5sdxm5b49'
2021-02-18T20:10:00.021065748Z   }
2021-02-18T20:10:00.021068547Z }
2021-02-18T20:10:00.021105138Z /participant/U2932822766/activity/46m9vtdwdzc5sdxm5b49
**2021-02-18T20:10:00.021110034Z Push gateway address is not defined**
2021-02-18T20:10:00.022289033Z Completed  job state on 46m9vtdwdzc5sdxm5b49
2021-02-18T20:10:00.026077663Z locked job on 46m9vtdwdzc5sdxm5b49
2021-02-18T20:10:00.026092824Z jobs in queue
2021-02-18T20:10:00.030052442Z {
2021-02-18T20:10:00.030076659Z   device_token: '91e78f48e9d16e13fcdba7bacfb72b0117eb01d52f44b6022e3cf448c6b13021',
2021-02-18T20:10:00.030080125Z   device_type: 'ios',
2021-02-18T20:10:00.030091057Z   payload: {
2021-02-18T20:10:00.030093949Z     participant_id: 'U2932822766',
2021-02-18T20:10:00.030109510Z     activity_id: 'wqcszngqgawy6exm35h2',
2021-02-18T20:10:00.030114131Z     message: 'You have a mindLAMP activity waiting for you: Test Survey.',
2021-02-18T20:10:00.030117019Z     title: 'Test Survey',
2021-02-18T20:10:00.030119756Z     url: '/participant/U2932822766/activity/wqcszngqgawy6exm35h2'
2021-02-18T20:10:00.030122587Z   }
2021-02-18T20:10:00.030125349Z }
2021-02-18T20:10:00.030186919Z /participant/U2932822766/activity/wqcszngqgawy6exm35h2
**2021-02-18T20:10:00.030212185Z Push gateway address is not defined**
2021-02-18T20:10:00.030504128Z Completed  job state on wqcszngqgawy6exm35h2
2021-02-18T20:10:00.037715239Z activity_id given 46m9vtdwdzc5sdxm5b49
2021-02-18T20:10:00.037739341Z Saving to redis
2021-02-18T20:10:00.037781410Z Processing 1 activities for push notifications.
2021-02-18T20:10:00.037792159Z locked job on activity_scheduler
2021-02-18T20:10:00.040742593Z actvityId 46m9vtdwdzc5sdxm5b49
2021-02-18T20:10:00.081983867Z participantslength 3
2021-02-18T20:10:00.407259323Z Saving to Redis completed....
2021-02-18T20:10:00.407300924Z release lock  on success  activity_scheduler
2021-02-18T20:10:00.407306880Z Rescheduled job after notificcation process-  46m9vtdwdzc5sdxm5b49
2021-02-18T20:10:00.407311842Z release lock  on success  46m9vtdwdzc5sdxm5b49
2021-02-18T20:10:00.407315438Z locked job on wqcszngqgawy6exm35h2
2021-02-18T20:10:00.407319249Z jobs in queue
2021-02-18T20:10:00.412234767Z activity_id given wqcszngqgawy6exm35h2
2021-02-18T20:10:00.412259943Z Saving to redis
2021-02-18T20:10:00.412264011Z Processing 1 activities for push notifications.
2021-02-18T20:10:00.412267268Z locked job on activity_scheduler
2021-02-18T20:10:00.414035525Z actvityId wqcszngqgawy6exm35h2
GET /type/kgpvyzbj098zyevz78bv/attachment/lamp.dashboard.survey_description 304 - 233.287 ms
GET /type/2vhcsxak8v88vj8t0rcb/attachment/lamp.dashboard.survey_description 304 - 234.565 ms
GET /type/46m9vtdwdzc5sdxm5b49/attachment/lamp.dashboard.activity_details 404 - 235.107 ms
Saving to Redis completed....
release lock  on success  activity_scheduler
processed 46m9vtdwdzc5sdxm5b49
release lock  on success  46m9vtdwdzc5sdxm5b49
completed job on 46m9vtdwdzc5sdxm5b49
GET /type/xw07pgy2257a8m0dd4h5/attachment/lamp.dashboard.survey_description 304 - 203.468 ms
GET /type/mk8bfw38sghm7ng92fkc/attachment/lamp.dashboard.survey_description 304 - 203.621 ms
GET /type/gmr8jv48ce8ve7mkdbsd/attachment/lamp.dashboard.survey_description 304 - 211.291 ms
GET /type/8amhwenggvx013w37vy5/attachment/lamp.dashboard.survey_description 304 - 209.387 ms
GET /type/xdcbckh2bzb0tjrm9k33/attachment/lamp.dashboard.survey_description 304 - 208.596 ms
GET /type/s9wjamynp0kyfd9fef29/attachment/lamp.dashboard.survey_description 304 - 195.367 ms
POST /participant/U6383026387/sensor_event 200 - 12.316 ms
GET /participant/U6383026387/activity_event?from=1613628000723&to=1613714400723 200 - 19.390 ms
GET /type/U6383026387/attachment/lamp.feed.goals 404 - 56.247 ms
GET /type/4gjfjbjpekjnyce41cqa/attachment/lamp.dashboard.survey_description 304 - 102.789 ms
GET /type/U6383026387/attachment/lamp.feed.medications 404 - 34.760 ms
POST /participant/U6383026387/sensor_event 200 - 9.699 ms
GET /type/6h1d9as9jz6c7acayhm1/attachment/lamp.dashboard.activity_details 304 - 83.426 ms
POST /participant/U6383026387/sensor_event 200 - 10.774 ms
GET /type/U6383026387/attachment/lamp.dashboard.disable_data 404 - 35.179 ms
{ docs: [], bookmark: 'nil' }
{ docs: [], bookmark: 'nil' }
{
�
[
    {
      _id: 'ccd329562c58c95224b612622c032b4c',
      _rev: '26-9d3342a3100ef71ccdc064b2e259aec9',
      '#parent': '7vs81xf3w38dec5dsd64',
      type: 'Participant',
      key: 'lamp.dashboard.credential_roles.external',
      value: {}
    }
  ],
  bookmark: 'g1AAAACneJw1y0sOgjAQBuAGNyYmrjyAS1dEprTCLbwBGWbGUC2PtI3i7aULl__j80qpYihYHWPCkF7y7Xgmx-PWn4lYQ2sskGmoNQB1byuwAHTV0NeU3f7v_CZ2mZ1u79hU60N_dMNChiPbOg-H-_Z05BacUs4Xj-NSMsahnzFwSUFYpuTQd2H2EktZk4QJ_fP5A997MdI'
}
{ docs: [], bookmark: 'nil' }
{ docs: [], bookmark: 'nil' }
{
�
[
    {
      _id: 'dd2b571140023c4ffffacb3cd84f64d5',
      _rev: '2-eb60ebbd2f5a4198e67fd6dc63db0656',
      '#parent': 'U6383026387',
      type: 'me',
      key: 'lamp.dashboard.credential_roles',
      value: [Object]
    },
    {
      _id: 'dd2b571140023c4ffffacb3cd84f6f83',
      _rev: '1-06c540d1b3755d3d7fb3fe6ad38e8986',
      '#parent': 'U6383026387',
      type: 'me',
      key: 'lamp.dashboard.credential_roles',
      value: [Object]
    },
    {
      _id: 'dd2b571140023c4ffffacb3cd84f4d90',
      _rev: '1-63b12827171531ae269f46e377e643cf',
      '#parent': 'U6383026387',
      type: 'me',
      key: 'lamp.name',
      value: 'DJ'
    },
    {
      _id: '432b58b535091f752330adbc41de4b8f',
      _rev: '3-04da493a725982422185768c3414f96f',
      '#parent': 'U6383026387',
      type: 'me',
      key: 'lamp.selectedActivities',
      value: [Array]
    }
  ],
  bookmark: 'g1AAAACEeJzLYWBgYMpgSmHgKy5JLCrJTq2MT8lPzkzJBYormBgbJZlaJJkamxpYGqaZmxoZGxskpiQlmximpJokWaSB9HHA9OUAdTCDtHGHmhlbGBsYAUlzEJ8pNxVEieck5hboFafmpCaXpKY4JpdklmWWZKYWZ2UBAMrHI54'
}

GET /type/U6383026387/attachment 304 - 41.180 ms
GET /type/U6383026387/attachment/lamp.selectedActivities 304 - 33.191 ms
GET /type/U6383026387/attachment/lamp.selectedSensors 404 - 36.305 ms
GET /type/U6383026387/attachment/lamp.selectedExperimental 404 - 37.683 ms
GET /participant/U6383026387/activity 200 - 14.992 ms
GET /type/U6383026387/attachment/lamp.dashboard.custom_survey_groups 404 - 33.681 ms
GET /participant/U6383026387/activity_event 304 - 8.113 ms
GET /participant/U6383026387/sensor_event 200 - 62.291 ms
GET / 200 - 4.393 ms
GET /participant/7vs81xf3w38dec5dsd64/sensor_event?origin=lamp.analytics 304 - 17.986 ms
GET /type/7vs81xf3w38dec5dsd64/attachment/lamp.messaging 404 - 26.134 ms
GET / 200 - 4.211 ms
GET / 200 - 4.581 ms
GET /participant/U6383026387/sensor_event 200 - 60.849 ms
GET /participant/7vs81xf3w38dec5dsd64/sensor_event?origin=lamp.analytics 304 - 12.569 ms
GET /type/7vs81xf3w38dec5dsd64/attachment/lamp.messaging 404 - 25.339 ms
GET / 200 - 5.501 ms
GET / 200 - 5.664 ms
GET /participant/7vs81xf3w38dec5dsd64/sensor_event?origin=lamp.analytics 304 - 21.052 ms
GET /type/7vs81xf3w38dec5dsd64/attachment/lamp.messaging 404 - 38.092 ms
GET / 200 - 6.774 ms
@jeydude1 jeydude1 added NO ETA No "days of effort required" assigned yet backend LAMP-server, LAMP-worker, and LAMP-app-gateway bug Something isn't working frontend LAMP-dashboard, LAMP-activities, and LAMP-js native core LAMP-core-ios, LAMP-swift, LAMP-core-android, and LAMP-kotlin labels Feb 18, 2021
@avaidyam avaidyam assigned Linoy339 and unassigned avaidyam Feb 18, 2021
@avaidyam avaidyam removed frontend LAMP-dashboard, LAMP-activities, and LAMP-js native core LAMP-core-ios, LAMP-swift, LAMP-core-android, and LAMP-kotlin labels Feb 18, 2021
@jeydude1
Copy link
Author

jeydude1 commented Feb 19, 2021

After looking at your iOS code from git repository

I have added following environment variables in the LAMP API Server stack
APP_GATEWAY: 'app-gateway.lamp.digital'
PUSH_GATEWAY_APIKEY: 'PUSH KEY We got from Rebecca'

Now I am getting

Error encountered sending APN push notification.

Please let me know if you need any more information on this. Thanks!

@avaidyam
Copy link
Member

@jeydude1 it should be APP_GATEWAY and PUSH_API_KEY instead, please try that.

@jeydude1
Copy link
Author

jeydude1 commented Feb 19, 2021

Thanks Aditya, Getting Error encountered sending APN push notification.

version: '3.7'
services:
  server:
    image: bidmcdigitalpsychiatry/lamp-server:2021
    healthcheck:
      test: wget --no-verbose --tries=1 --spider http://localhost:3000 || exit 1
    environment:
      HTTPS: 'off'
      SCHEDULER: 'on'
      ROOT_KEY: ''
      CDB: 'http://@database:5984/'
      APP_GATEWAY: 'app-gateway.lamp.digital'
      PUSH_API_KEY: 'API Key from MindLAMP team'
      DASHBOARD_URL: 'dashboard.lamp.digital'
      REDIS_HOST: 'redis://cache:6379/0'
      NATS_SERVER: 'message_queue:4222'
GET / 200 - 4.400 ms
GET / 200 - 6.335 ms
{
  device_token: '91b298a9365152582bd24953e11a206d6989aca0c3555f27b392767fc9c64b47',
  device_type: 'ios',
  payload: {
    participant_id: 'U2932822766',
    activity_id: 'wqcszngqgawy6exm35h2',
    message: 'You have a mindLAMP activity waiting for you: Test Survey.',
    title: 'Test Survey',
    url: '/participant/U2932822766/activity/wqcszngqgawy6exm35h2'
  }
}
/participant/U2932822766/activity/wqcszngqgawy6exm35h2
Completed  job state on wqcszngqgawy6exm35h2
locked job on wqcszngqgawy6exm35h2
jobs in queue
activity_id given wqcszngqgawy6exm35h2
Saving to redis
Processing 1 activities for push notifications.
locked job on activity_scheduler
actvityId wqcszngqgawy6exm35h2
participantslength 4
Saving to Redis completed....
release lock  on success  activity_scheduler
Rescheduled job after notificcation process-  wqcszngqgawy6exm35h2
release lock  on success  wqcszngqgawy6exm35h2
Error encountered sending APN push notification.
GET / 200 - 9.456 ms
GET / 200 - 4.774 ms

@avaidyam
Copy link
Member

@jeydude1 Hmm, that is odd. @Linoy339 should be able to assist you in debugging these issues so I will have him take it from here.

@jeydude1
Copy link
Author

@Linoy339, please let me know if you need anything from me to avoid getting Error encountered sending APN push notification. Thanks!

@Linoy339
Copy link

@jeydude1 . We can investigate it. Is the device token given above valid?
We can try sending a push with this device token and let us find this.

@jeydude1
Copy link
Author

jeydude1 commented Feb 22, 2021

@Linoy339, Here is most recent one push notification message and failure message, let me know if you need anything. I have reinstalled the mindLAMP app on my iphone 7 plus and confirmed push notification and other settings are ON. Still not getting push notification message. If you want to send test push notification message feel free to do it. Use this device token - 883a6cb555143bb20013b9fd07d8261aca1f484cf2ac32a28f7e010edea9120c

2021-02-22T17:44:17.515441734Z GET / 200 - 5.666 ms
2021-02-22T17:44:47.863471866Z GET / 200 - 4.865 ms
2021-02-22T17:44:50.705243848Z GET /participant/7vs81xf3w38dec5dsd64/sensor_event?origin=lamp.analytics 304 - 19.414 ms
2021-02-22T17:44:50.719958074Z GET /type/7vs81xf3w38dec5dsd64/attachment/lamp.messaging 404 - 34.217 ms
2021-02-22T17:45:00.086288990Z {
2021-02-22T17:45:00.086315450Z   device_token: '883a6cb555143bb20013b9fd07d8261aca1f484cf2ac32a28f7e010edea9120c',
2021-02-22T17:45:00.086319439Z   device_type: 'ios',
2021-02-22T17:45:00.086322707Z   payload: {
2021-02-22T17:45:00.086325680Z     participant_id: 'U2932822766',
2021-02-22T17:45:00.086328604Z     activity_id: 'kgpvyzbj098zyevz78bv',
2021-02-22T17:45:00.086331466Z     message: 'You have a mindLAMP activity waiting for you: Symptom Severity Ratings.',
2021-02-22T17:45:00.086334389Z     title: 'Symptom Severity Ratings',
2021-02-22T17:45:00.086337239Z     url: '/participant/U2932822766/activity/kgpvyzbj098zyevz78bv'
2021-02-22T17:45:00.086340244Z   }
2021-02-22T17:45:00.086342947Z }
2021-02-22T17:45:00.086345662Z /participant/U2932822766/activity/kgpvyzbj098zyevz78bv
2021-02-22T17:45:00.105960987Z Completed  job state on kgpvyzbj098zyevz78bv
2021-02-22T17:45:00.105994328Z locked job on kgpvyzbj098zyevz78bv
2021-02-22T17:45:00.106000006Z jobs in queue
2021-02-22T17:45:00.115159862Z activity_id given kgpvyzbj098zyevz78bv
2021-02-22T17:45:00.115222306Z Saving to redis
2021-02-22T17:45:00.115228851Z Processing 1 activities for push notifications.
2021-02-22T17:45:00.115233422Z locked job on activity_scheduler
2021-02-22T17:45:00.117466710Z actvityId kgpvyzbj098zyevz78bv
2021-02-22T17:45:00.197242323Z participantslength 4
2021-02-22T17:45:00.772852353Z Saving to Redis completed....
2021-02-22T17:45:00.772882871Z release lock  on success  activity_scheduler
2021-02-22T17:45:00.772886840Z Rescheduled job after notificcation process-  kgpvyzbj098zyevz78bv
2021-02-22T17:45:00.772890042Z release lock  on success  kgpvyzbj098zyevz78bv
2021-02-22T17:45:05.103079153Z Error encountered sending APN push notification.
2021-02-22T17:45:18.203684373Z GET / 200 - 14.922 ms
2021-02-22T17:45:48.554798882Z GET / 200 - 5.987 ms
2021-02-22T17:45:50.692380615Z GET /participant/7vs81xf3w38dec5dsd64/sensor_event?origin=lamp.analytics 304 - 19.913 ms
2021-02-22T17:45:50.742398055Z GET /type/7vs81xf3w38dec5dsd64/attachment/lamp.messaging 404 - 29.685 ms
2021-02-22T17:46:18.889187481Z GET / 200 - 4.662 ms
2021-02-22T17:46:33.743176483Z POST /participant/U2932822766/sensor_event 200 - 1245.474 ms
2021-02-22T17:46:36.800600578Z POST /participant/U2932822766/sensor_event 200 - 1302.662 ms
2021-02-22T17:46:49.221464053Z GET / 200 - 5.983 ms
2021-02-22T17:46:50.700353600Z GET /participant/7vs81xf3w38dec5dsd64/sensor_event?origin=lamp.analytics 304 - 19.540 ms
2021-02-22T17:46:50.760473776Z GET /type/7vs81xf3w38dec5dsd64/attachment/lamp.messaging 404 - 30.159 ms
2021-02-22T17:47:19.565070783Z GET / 200 - 5.305 ms
2021-02-22T17:47:49.912983195Z GET / 200 - 4.910 ms
2021-02-22T17:47:50.687676876Z GET /participant/7vs81xf3w38dec5dsd64/sensor_event?origin=lamp.analytics 304 - 19.228 ms
2021-02-22T17:47:50.741814200Z GET /type/7vs81xf3w38dec5dsd64/attachment/lamp.messaging 404 - 35.263 ms
2021-02-22T17:48:20.251953758Z GET / 200 - 5.147 ms
2021-02-22T17:48:50.586313614Z GET / 200 - 5.022 ms
2021-02-22T17:48:50.691050237Z GET /participant/7vs81xf3w38dec5dsd64/sensor_event?origin=lamp.analytics 304 - 21.985 ms
2021-02-22T17:48:50.746946233Z GET /type/7vs81xf3w38dec5dsd64/attachment/lamp.messaging 404 - 30.495 ms
2021-02-22T17:49:20.946127636Z GET / 200 - 6.309 ms
2021-02-22T17:49:50.682205582Z GET /participant/7vs81xf3w38dec5dsd64/sensor_event?origin=lamp.analytics 304 - 14.065 ms
2021-02-22T17:49:50.720563638Z GET /type/7vs81xf3w38dec5dsd64/attachment/lamp.messaging 404 - 26.733 ms
2021-02-22T17:49:51.281178625Z GET / 200 - 6.053 ms

@jeydude1
Copy link
Author

IMG_1275
IMG_1274

@jeydude1
Copy link
Author

Got your test message on my iphone

@Linoy339
Copy link

Okay

@jeydude1
Copy link
Author

Got another test message

@jeydude1
Copy link
Author

jeydude1 commented Feb 22, 2021

Can you send this

GET / 200 - 5.289 ms
{
  device_token: '883a6cb555143bb20013b9fd07d8261aca1f484cf2ac32a28f7e010edea9120c',
  device_type: 'ios',
  payload: {
    participant_id: 'U2932822766',
    activity_id: 'wqcszngqgawy6exm35h2',
    message: 'You have a mindLAMP activity waiting for you: Test Survey.',
    title: 'Test Survey',
    url: '/participant/U2932822766/activity/wqcszngqgawy6exm35h2'
  }
}

@jeydude1
Copy link
Author

Interesting, got above push notification on my phone. Manual testing looks good

@jeydude1
Copy link
Author

jeydude1 commented Feb 22, 2021

any reason why API server is still erroring out - 2021-02-22T17:45:05.103079153Z Error encountered sending APN push notification.

@Linoy339
Copy link

@jeydude1 . May I confirm that no participants are getting notifications ?

@jeydude1
Copy link
Author

jeydude1 commented Feb 22, 2021

Currently I am the only user/tester who has iPhone and others are having android phones. They have mindLAMP to Google Fit connection issue. So they are not able to test the push notification.

@Linoy339
Copy link

Okay @jeydude1

@Linoy339
Copy link

@jeydude1 Can you restart the api server once, as we doubt that environment variables might not got reflected in api server?

@jeydude1
Copy link
Author

jeydude1 commented Feb 22, 2021

Redeployed the whole stack, still erroring out...

Here is the yaml configuration for API server.

version: '3.7'
services:
  server:
    image: bidmcdigitalpsychiatry/lamp-server:2021
    healthcheck:
      test: wget --no-verbose --tries=1 --spider http://localhost:3000 || exit 1
    environment:
      HTTPS: 'off'
      SCHEDULER: 'on'
      ROOT_KEY: 'fd804de0e9fb5bec33e888ad27c0ede41d39ff8e520c8a38fd8515618064ce24'
      CDB: 'http://admin:yourpassword@database:5984/'
      APP_GATEWAY: 'app-gateway.lamp.digital'
      PUSH_API_KEY: 'key from rebecca'
      DASHBOARD_URL: 'dashboard.lamp.digital'
      REDIS_HOST: 'redis://cache:6379/0'
      NATS_SERVER: 'message_queue:4222'
    networks:
      - default
      - public
    deploy:
      mode: replicated
      update_config:
        order: start-first
        failure_action: rollback
      labels:
         traefik.enable: 'true'
         traefik.http.routers.lamp_server.entryPoints: 'websecure'
         traefik.http.routers.lamp_server.rule: 'Host(`hostname`)'
         traefik.http.routers.lamp_server.tls.certresolver: 'default'
         traefik.http.services.lamp_server.loadbalancer.server.port: 3000
         traefik.docker.network: 'public'
      placement:
        constraints:
          - node.role == manager 

Here is the API server log:

2021-02-22T18:53:57.394654257Z Initializing LAMP API server...
2021-02-22T18:53:57.395770285Z   Initializing database connection...
2021-02-22T18:53:57.419120278Z     Connected to Nats Pub Server
2021-02-22T18:53:57.419310861Z     Connected to Nats Sub Server
2021-02-22T18:53:57.533140055Z     ActivitySpec database online.
2021-02-22T18:53:57.533175799Z     SensorSpec database online.
2021-02-22T18:53:57.533182127Z     Researcher database online.
2021-02-22T18:53:57.533209451Z     Study database online.
2021-02-22T18:53:57.533248213Z     Participant database online.
2021-02-22T18:53:57.533253882Z     Activity database online.
2021-02-22T18:53:57.533293258Z     Sensor database online.
2021-02-22T18:53:57.533298284Z     ActivityEvent database online.
2021-02-22T18:53:57.533326361Z     SensorEvent database online.
2021-02-22T18:53:57.533333738Z     Credential database online.
2021-02-22T18:53:57.533361301Z     Tag database online.
2021-02-22T18:53:57.533413890Z   Database verification complete.
2021-02-22T18:53:57.534186910Z   Server routing initialized.
2021-02-22T18:53:57.534285607Z   Clean all queues...
2021-02-22T18:53:57.534795633Z   CLEANING ALL QUEUE
2021-02-22T18:53:57.542917010Z   DONE--CLEANING ALL QUEUE
2021-02-22T18:53:57.542946698Z   Initializing schedulers...
2021-02-22T18:53:57.545183137Z Initialization complete.
2021-02-22T18:53:57.869183514Z activity_id given undefined
2021-02-22T18:53:57.869210066Z Saving to redis
2021-02-22T18:53:57.869234171Z Processing 30 activities for push notifications.
2021-02-22T18:53:57.869867055Z locked job on activity_scheduler
2021-02-22T18:53:57.870968552Z actvityId wqcszngqgawy6exm35h2
2021-02-22T18:53:57.963771652Z participantslength 4
2021-02-22T18:53:58.472505510Z actvityId xgkpc0q2wb9jk06cfdxf
2021-02-22T18:53:58.472656474Z actvityId f8emztwhnxqeyrak835b
2021-02-22T18:53:58.472862436Z actvityId h2x1sm5y4hrys6p321df
2021-02-22T18:53:58.473045021Z actvityId 26szk8cttcbsv9ngnec5
2021-02-22T18:53:58.473261289Z actvityId qw774h2mm2e5j88cg58d
2021-02-22T18:53:58.525923329Z participantslength 4
2021-02-22T18:53:58.957979320Z actvityId cq3b1p6pqgrtzkdpt416
2021-02-22T18:53:58.958134764Z actvityId kgpvyzbj098zyevz78bv
2021-02-22T18:53:58.999778511Z participantslength 4
2021-02-22T18:53:59.445856873Z actvityId 2vhcsxak8v88vj8t0rcb
2021-02-22T18:53:59.446056402Z actvityId 6pzj92q6ccaw8741wsts
2021-02-22T18:53:59.446234766Z actvityId t9ghgn8hn91c34wtp606
2021-02-22T18:53:59.446395047Z actvityId gmr8jv48ce8ve7mkdbsd
2021-02-22T18:53:59.446570163Z actvityId 8amhwenggvx013w37vy5
2021-02-22T18:53:59.446763581Z actvityId mk8bfw38sghm7ng92fkc
2021-02-22T18:53:59.446958182Z actvityId xdcbckh2bzb0tjrm9k33
2021-02-22T18:53:59.447176214Z actvityId xw07pgy2257a8m0dd4h5
2021-02-22T18:53:59.447371023Z actvityId s9wjamynp0kyfd9fef29
2021-02-22T18:53:59.447535387Z actvityId 4gjfjbjpekjnyce41cqa
2021-02-22T18:53:59.447693695Z actvityId bfx54bdsf6fgp7kfdyrs
2021-02-22T18:53:59.486171824Z participantslength 1
2021-02-22T18:53:59.547637382Z actvityId 472cf23t24eb32yj0nbx
2021-02-22T18:53:59.588517329Z participantslength 1
2021-02-22T18:53:59.647457238Z actvityId 7zfymq54wncnzstk2f53
2021-02-22T18:53:59.686335631Z participantslength 2
2021-02-22T18:53:59.706955695Z actvityId 6w6ejdmjxhzs2wm6b5bp
2021-02-22T18:53:59.708012550Z actvityId y8rksht24gsjdf43aydt
2021-02-22T18:53:59.708032113Z actvityId a1sfhvgppr2m593qhsj0
2021-02-22T18:53:59.754187956Z participantslength 1
2021-02-22T18:53:59.791970313Z actvityId khp9tv894k2ew5fg3ydb
2021-02-22T18:53:59.828244640Z participantslength 1
2021-02-22T18:53:59.852228461Z actvityId 46m9vtdwdzc5sdxm5b49
2021-02-22T18:53:59.896309837Z participantslength 4
2021-02-22T18:54:00.334595132Z actvityId 67vgt8869j6rm3saqewh
2021-02-22T18:54:00.334834212Z actvityId msv3g9p4n3by8fk77tds
2021-02-22T18:54:00.335045281Z actvityId 6h1d9as9jz6c7acayhm1
2021-02-22T18:54:00.335268957Z actvityId qva6jdyb478tyfeteq15
2021-02-22T18:54:00.373249149Z participantslength 4
2021-02-22T18:54:00.769458068Z Saving to Redis completed....
2021-02-22T18:54:00.769563810Z release lock  on success  activity_scheduler
2021-02-22T18:54:23.772351601Z GET / 200 - 10.331 ms
2021-02-22T18:54:46.607177967Z GET /participant/7vs81xf3w38dec5dsd64/sensor_event?origin=lamp.analytics 200 - 34.040 ms
2021-02-22T18:54:46.624748649Z GET /type/7vs81xf3w38dec5dsd64/attachment/lamp.messaging 404 - 56.511 ms
2021-02-22T18:54:51.186824719Z GET /researcher/7vs81xf3w38dec5dsd64/study 304 - 45.765 ms
2021-02-22T18:54:51.198050163Z GET /activity_spec 304 - 35.358 ms
2021-02-22T18:54:51.245568094Z GET /type/7vs81xf3w38dec5dsd64/attachment/lamp.selectedStudies 404 - 36.552 ms
2021-02-22T18:54:51.312867698Z GET /type/7vs81xf3w38dec5dsd64/attachment/lamp.selectedStudies 404 - 30.983 ms
2021-02-22T18:54:51.379514973Z GET /study/9gtkbw0sgsqkbs5mdaas/activity 304 - 19.678 ms
2021-02-22T18:54:51.385604977Z GET /study/bze1t66jkra2ngdtzrv2/activity 304 - 33.388 ms
2021-02-22T18:54:51.422854551Z GET /study/9gtkbw0sgsqkbs5mdaas/activity 304 - 19.054 ms
2021-02-22T18:54:51.432008875Z GET /study/bze1t66jkra2ngdtzrv2/activity 304 - 25.384 ms
2021-02-22T18:54:54.198478392Z GET / 200 - 7.757 ms
2021-02-22T18:55:10.254235328Z PUT /activity/qva6jdyb478tyfeteq15 200 - 65.183 ms
2021-02-22T18:55:10.264255641Z locked job on qva6jdyb478tyfeteq15
2021-02-22T18:55:10.345217829Z activity_id given qva6jdyb478tyfeteq15
2021-02-22T18:55:10.345242600Z Saving to redis
2021-02-22T18:55:10.345247481Z Processing 1 activities for push notifications.
2021-02-22T18:55:10.345303599Z locked job on activity_scheduler
2021-02-22T18:55:10.346106711Z actvityId qva6jdyb478tyfeteq15
2021-02-22T18:55:10.424251205Z participantslength 4
2021-02-22T18:55:10.455528849Z GET /study/9gtkbw0sgsqkbs5mdaas/activity 304 - 31.868 ms
2021-02-22T18:55:10.468396460Z GET /study/bze1t66jkra2ngdtzrv2/activity 200 - 46.204 ms
2021-02-22T18:55:10.503084786Z GET /study/9gtkbw0sgsqkbs5mdaas/activity 304 - 21.264 ms
2021-02-22T18:55:10.520236802Z GET /study/bze1t66jkra2ngdtzrv2/activity 304 - 25.232 ms
2021-02-22T18:55:10.937142912Z Saving to Redis completed....
2021-02-22T18:55:10.937183156Z release lock  on success  activity_scheduler
2021-02-22T18:55:10.937188391Z processed qva6jdyb478tyfeteq15
2021-02-22T18:55:10.937191723Z release lock  on success  qva6jdyb478tyfeteq15
2021-02-22T18:55:10.937194713Z completed job on qva6jdyb478tyfeteq15
2021-02-22T18:55:24.591243558Z GET / 200 - 6.341 ms
2021-02-22T18:55:46.559144782Z GET /participant/7vs81xf3w38dec5dsd64/sensor_event?origin=lamp.analytics 304 - 22.769 ms
2021-02-22T18:55:46.574004906Z GET /type/7vs81xf3w38dec5dsd64/attachment/lamp.messaging 404 - 35.434 ms
2021-02-22T18:55:55.023376055Z GET / 200 - 7.821 ms
2021-02-22T18:56:13.183386861Z PUT /activity/qva6jdyb478tyfeteq15 200 - 19.804 ms
2021-02-22T18:56:13.183398345Z locked job on qva6jdyb478tyfeteq15
2021-02-22T18:56:13.189262317Z activity_id given qva6jdyb478tyfeteq15
2021-02-22T18:56:13.189293287Z Saving to redis
2021-02-22T18:56:13.189297462Z Processing 1 activities for push notifications.
2021-02-22T18:56:13.189300788Z locked job on activity_scheduler
2021-02-22T18:56:13.191816326Z actvityId qva6jdyb478tyfeteq15
2021-02-22T18:56:13.288625447Z participantslength 4
2021-02-22T18:56:13.382220180Z GET /study/bze1t66jkra2ngdtzrv2/activity 200 - 28.830 ms
2021-02-22T18:56:13.401845917Z GET /study/9gtkbw0sgsqkbs5mdaas/activity 304 - 14.292 ms
2021-02-22T18:56:13.426445469Z GET /study/bze1t66jkra2ngdtzrv2/activity 304 - 19.927 ms
2021-02-22T18:56:13.439677071Z GET /study/9gtkbw0sgsqkbs5mdaas/activity 304 - 16.748 ms
2021-02-22T18:56:13.776204812Z Saving to Redis completed....
2021-02-22T18:56:13.776234007Z release lock  on success  activity_scheduler
2021-02-22T18:56:13.776239497Z processed qva6jdyb478tyfeteq15
2021-02-22T18:56:13.776263900Z release lock  on success  qva6jdyb478tyfeteq15
2021-02-22T18:56:13.776268611Z completed job on qva6jdyb478tyfeteq15
2021-02-22T18:56:25.366943215Z GET / 200 - 7.453 ms
2021-02-22T18:56:46.555835898Z GET /participant/7vs81xf3w38dec5dsd64/sensor_event?origin=lamp.analytics 304 - 18.292 ms
2021-02-22T18:56:46.569905352Z GET /type/7vs81xf3w38dec5dsd64/attachment/lamp.messaging 404 - 33.498 ms
2021-02-22T18:56:55.722036040Z GET / 200 - 6.466 ms
2021-02-22T18:57:26.066499252Z GET / 200 - 4.641 ms
2021-02-22T18:57:46.530781694Z GET /participant/7vs81xf3w38dec5dsd64/sensor_event?origin=lamp.analytics 304 - 13.674 ms
2021-02-22T18:57:46.586734624Z GET /type/7vs81xf3w38dec5dsd64/attachment/lamp.messaging 404 - 33.191 ms
2021-02-22T18:57:56.461350193Z GET / 200 - 4.750 ms
2021-02-22T18:58:02.959847487Z {
2021-02-22T18:58:02.959897454Z   device_token: '883a6cb555143bb20013b9fd07d8261aca1f484cf2ac32a28f7e010edea9120c',
2021-02-22T18:58:02.959901699Z   device_type: 'ios',
2021-02-22T18:58:02.959904759Z   payload: {
2021-02-22T18:58:02.959907672Z     participant_id: 'U2932822766',
2021-02-22T18:58:02.959910658Z     activity_id: 'qva6jdyb478tyfeteq15',
2021-02-22T18:58:02.959913534Z     message: 'You have a mindLAMP activity waiting for you: Sample Survey.',
2021-02-22T18:58:02.959916576Z     title: 'Sample Survey',
2021-02-22T18:58:02.959919408Z     url: '/participant/U2932822766/activity/qva6jdyb478tyfeteq15'
2021-02-22T18:58:02.959922347Z   }
2021-02-22T18:58:02.959925089Z }
2021-02-22T18:58:02.959982436Z /participant/U2932822766/activity/qva6jdyb478tyfeteq15
2021-02-22T18:58:02.983555870Z Completed  job state on qva6jdyb478tyfeteq15
2021-02-22T18:58:02.983613659Z locked job on qva6jdyb478tyfeteq15
2021-02-22T18:58:02.983662017Z jobs in queue
2021-02-22T18:58:02.989170096Z activity_id given qva6jdyb478tyfeteq15
2021-02-22T18:58:02.989232371Z Saving to redis
2021-02-22T18:58:02.989242211Z Processing 1 activities for push notifications.
2021-02-22T18:58:02.989280683Z locked job on activity_scheduler
2021-02-22T18:58:02.991004320Z actvityId qva6jdyb478tyfeteq15
2021-02-22T18:58:03.045429250Z participantslength 4
2021-02-22T18:58:03.522254113Z Saving to Redis completed....
2021-02-22T18:58:03.522274017Z release lock  on success  activity_scheduler
2021-02-22T18:58:03.522277901Z Rescheduled job after notificcation process-  qva6jdyb478tyfeteq15
2021-02-22T18:58:03.522282656Z release lock  on success  qva6jdyb478tyfeteq15
2021-02-22T18:58:07.990192013Z Error encountered sending APN push notification.

@jeydude1
Copy link
Author

jeydude1 commented Feb 22, 2021

I believe you guys are not printing actual exception object error message in the log, may be printing exception object might help

@Linoy339
Copy link

Linoy339 commented Feb 23, 2021

@jeydude1. This is not the reason.
There would be two sets of data while login. One will be as stated by you (above).
Another one would be with device details with "action" as "login":

{
      _id: XXXX,
       '#parent': XXX,
      timestamp: 1610089361747,
      sensor: 'lamp.analytics',
      data: {
        action: 'login',
        user_agent: '1.1.3, iPhone, 14.3',
        device_token: '387XXXXXXXXXXXe37945f9b3d20bXXXXXXXXXXXXca3fXXXXXXXXae9',
        device_type: 'iOS' //or android
      }
    }

Please confirm that above data exists for android for the same user which you have stated above.

Regarding notifications, it seems no calls are sent to app-gateway for some network issues.

@jeydude1
Copy link
Author

jeydude1 commented Feb 23, 2021

@Linoy339, here is what I am seeing while user login to the application using their mobile app. Please try this on your end and confirm.

In android, while login to the mindLAMP android mobile application

  {
"timestamp": 1614090428235,
"sensor": "lamp.analytics",
"data": {
"device_type": "Dashboard",
"user_agent": "LAMP-dashboard/9beed4c Mozilla/5.0 (Linux; Android 7.0; HTCD160LVW Build/NRD90M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/86.0.4240.185 Mobile Safari/537.36"
}
}

for android users, I do not see any log with action login, tried from different phones same log message for android.

In iOS, while login to the mindLAMP iOS mobile app

  {
"timestamp": 1614057395414,
"sensor": "lamp.analytics",
"data": {
"action": "login",
"user_agent": "1.1.3, iPhone, 14.4",
"device_token": "883a6cb555143bb20013b9fd07d8261aca1f484cf2ac32a28f7e010edea9120c",
"device_type": "iOS"
}
}

@jeydude1
Copy link
Author

jeydude1 commented Feb 23, 2021

@Linoy339, About 'Error encountered sending APN push notification' in the code - https://github.com/BIDMCDigitalPsychiatry/LAMP-server/blob/master/src/utils/queue/SchedulerQueue.ts

To display error/exception message what do I need to do on my local server, if you have instructions please share. Thanks!

from:

            .catch((e) => {
              console.log("Error encountered sending APN push notification.")
            })
        } catch (error) {
          console.log(`"Error encountered sending APN push notification"-${error}`)
        }
        break

to:

            .catch((e) => {
              _console.log(`"Error encountered sending APN push notification"-${e}`)_
            })
        } catch (error) {
          console.log(`"Error encountered sending APN push notification"-${error}`)
        }
        break

@Linoy339
Copy link

Linoy339 commented Feb 23, 2021

Can you console the error like this:

.then((res) => {
console.log("response",res)
              if (!res.ok) {
                throw new Error(`HTTP error!`)
              }
            })
            .catch((e) => {
            console.log("e",e)
              console.log("Error encountered sending APN push notification.")
            })
        } catch (error) {
        console.log("error",error)
          console.log(`Error encountered sending APN push notification - ${error}`)
        }

@avaidyam
Copy link
Member

@jeydude1 @Linoy339 I realize both of you are not formatting the code in GitHub Markdown (use three of these `: ``` to open and close the code block). I've updated your comments to format the code correctly.

@jeydude1
Copy link
Author

Thanks for sharing the code, we are using your image "image: bidmcdigitalpsychiatry/lamp-server:2021" not sure how to update the image code, if you have instructions to get inside the image and update the code and redploy the updated image in the portainer, share with me, happy to try that. Thanks a lot!

@avaidyam
Copy link
Member

@jeydude1 If you have node and npm installed, you could git clone https://github.com/BIDMCDigitalPsychiatry/LAMP-server.git locally and then fill in the .env file with the same variables from your docker-compose.yml. Then, npm install, make the code change, and npm start.

@jeydude1
Copy link
Author

Thanks I will try that. Appreciate much for sharing the instructions

@avaidyam
Copy link
Member

Also another thing you may want to check is whether your firewall allows outgoing connections to app-gateway.lamp.digital. Another team we have worked with to deploy LAMP had to allowlist that specific domain.

@Linoy339
Copy link

Thanks @avaidyam .
@jeydude1. Please let us know after attempting it.

@jeydude1
Copy link
Author

jeydude1 commented Feb 23, 2021

I tried this from the centos server, i got the push notification to my iPhone, that confirms I am able to communicate with https://app-gateway.lamp.digital/push from centos sever.

curl -X POST -H "Content-Type: application/json" \
    -d '{"push_type":"apns","api_key":"API Key from Rebecca","device_token":"883a6cb555143bb20013b9fd07d8261aca1f484cf2ac32a28f7e010edea9120c","payload":{"aps":{"alert":"You have a mindLAMP activity waiting for you: Test Survey.","badge":0,"sound":"default","mutable-content":1,"content-available":1,"push-type":"alert","collapse-id":"1614094037619","expiration":10},"notificationId":"1614094037619","expiry":21600000,"page":"/participant/U2932822766/activity/wqcszngqgawy6exm35h2","actions":[{"name":"Open App","page":"/participant/U2932822766/activity/wqcszngqgawy6exm35h2"}]}}' \
    https://app-gateway.lamp.digital/push

I will need to install node and npm in the centos I will have to work with unix administrator for that. I will let you know what I find out.

@jeydude1
Copy link
Author

jeydude1 commented Feb 23, 2021

I could not deploy the API server package locally in centos , having issues with permissions.

Once you have the exception message added to the code, please let me know I can redeploy latest mindLAMP stacks. Thanks!

@jeydude1
Copy link
Author

jeydude1 commented Feb 23, 2021

We have 2 iphone users having issues with push notifications. And for Android users scheduler is not generating push notification messages:

{
  device_token: 'bf2ef64da706186535e709f0db6b665c3090d8c7324d832491e535ba7a171760',
  device_type: 'ios',
payload: {
    participant_id: 'U0766681068',
    activity_id: 'wqcszngqgawy6exm35h2',
    message: 'You have a mindLAMP activity waiting for you: Test Survey.',
    title: 'Test Survey',
    url: '/participant/U0766681068/activity/wqcszngqgawy6exm35h2'
  }
}
/participant/U0766681068/activity/wqcszngqgawy6exm35h2
{
  device_token: '883a6cb555143bb20013b9fd07d8261aca1f484cf2ac32a28f7e010edea9120c',
  device_type: 'ios',
�      
  payload: {
    participant_id: 'U2932822766',
    activity_id: 'wqcszngqgawy6exm35h2',
    message: 'You have a mindLAMP activity waiting for you: Test Srvey.',
    title: 'Test Survey',
    url: '/participant/U2932822766/activity/wqcszngqgawy6exm35h2'
  }
}
/participant/U2932822766/activity/wqcszngqgawy6exm35h2
Completed  job state on wqcszngqgawy6exm35h2
locked job on wqcszngqgawy6exm35h2
jobs in queue
Error encountered sending APN push notification.
Error encountered sending APN push notification.
activity_id given wqcszngqgawy6exm35h2
Saving to redis
Processing 1 activities for push notifications.
locked job on activity_scheduler
actvityId wqcszngqgawy6exm35h2
GET /participant/7vs81xf3w38dec5dsd64/sensor_event?origin=lamp.analytics 304 - 3353.279 ms
GET /type/7vs81xf3w38dec5dsd64/attachment/lamp.messaging 404 - 3374.550 ms
participantslength 5
Saving to Redis completed....
release lock  on success  activity_scheduler
Rescheduled job after notificcation process-  wqcszngqgawy6exm35h2
release lock  on success  wqcszngqgawy6exm35h2
GET / 200 - 5.946 ms
POST /participant/U2932822766/sensor_event 200 - 1379.789 ms
POST /participant/U2932822766/sensor_event 200 - 1300.831 ms

@jeydude1
Copy link
Author

jeydude1 commented Feb 24, 2021

@avaidyam thanks for updating the code and for the new release

while sending push notification to iOS devices here is the exception I am seeing and scheduler does not generate any push notification message for android devices.

"Error encountered sending APN push notification."--FetchError: request to https://app-gateway.lamp.digital/push failed, reason: getaddrinfo EAI_AGAIN app-gateway.lamp.digital

"Error encountered sending APN push notification."--FetchError: request to https://app-gateway.lamp.digital/push failed, reason: getaddrinfo EAI_AGAIN app-gateway.lamp.digital

Please let me know. Thanks!

@avaidyam
Copy link
Member

@jeydude1 This is an error on your deployments' end.

EAI_AGAIN means the DNS server replied that it cannot currently fulfill the request. (If you want the hairy details, the RCODE field in the response is set to 2, SERVFAIL.) There is no single solution because it entirely depends on why the DNS server sends that back. Maybe it's overloaded, maybe the network is down, maybe it got the same reply from its upstream server. In general, the best you can do is wait a while and try again. Hope that helps.

@jeydude1
Copy link
Author

jeydude1 commented Feb 24, 2021

@avaidyam Thanks, I tried to restart the docker container, restarted the docker, no luck. Still getting the error, I will try few more options. If I got it working I will let you know the solutions.

I just updated yaml configuration in the production CENT OS server. Push notification works in our production LAMP API server. Only test server has this issue.

@jeydude1
Copy link
Author

jeydude1 commented Feb 24, 2021

@avaidyam, @Linoy339 for Android users, we don't see scheduler generating push notification messages, let me know if you need any more information or open separate issue for this. Thanks!

@amaljofyzco
Copy link

Hi Jey,

Could you re check again, we are seeing it. check below screenshot line no: 13
Screenshot 2021-02-25 at 12 23 27 PM

@jeydude1
Copy link
Author

jeydude1 commented Feb 25, 2021

@amaljofyzco, here is what I see, I just downloaded and installed mindLAMP app from Android Play store app released on Dec 14 2020.

Here is what I see when I login to the android app.
image
Tried with Samsung phones also.
image

@jeydude1
Copy link
Author

@avaidyam I was able to fix the push notification in test server to avoid

"Error encountered sending APN push notification."--FetchError: request to https://app-gateway.lamp.digital/push failed, reason: getaddrinfo EAI_AGAIN app-gateway.lamp.digital

Solution, I have followed:
firewall-cmd --permanent --zone=docker --add-interface=docker_gwbridge
firewall-cmd --permanent --zone=trusted --remove-interface=docker0
firewall-cmd --permanent --zone=docker --add-interface=docker0
firewall-cmd --reload
systemctl restart docker

@jeydude1
Copy link
Author

jeydude1 commented Feb 25, 2021

@amaljofyzco, can you please try installing app from android play store and see if you are able to see the login action? Thanks!

I have mindLAMP version 1.2 on android phone. Even tried with beta version of play store app in android, no luck getting login action for android. Let me know if you want me to do anything else. Thanks!

@avaidyam
Copy link
Member

@jeydude1 Those steps seem specific to CentOS distributions and perhaps your specific organization as well. Thanks for sharing though - others that use CentOS may need to do the same.

@amaljofyzco
Copy link

@avaidyam I was able to fix the push notification in test server to avoid

"Error encountered sending APN push notification."--FetchError: request to https://app-gateway.lamp.digital/push failed, reason: getaddrinfo EAI_AGAIN app-gateway.lamp.digital

Solution, I have followed:
firewall-cmd --permanent --zone=docker --add-interface=docker_gwbridge
firewall-cmd --permanent --zone=trusted --remove-interface=docker0
firewall-cmd --permanent --zone=docker --add-interface=docker0
firewall-cmd --reload
systemctl restart docker

Hei JeyDude,

I have fixed the issue, it will be updated in the next update.
Thanks AMal

@avaidyam
Copy link
Member

@amaljofyzco Could you link the pull request on LAMP-core-android that fixed the issue here for record-keeping?

@jeydude1
Copy link
Author

Thanks @amaljofyzco for fixing the android app to capture login action so we can get push notification for Android. Thanks a lot! Waiting for official release!

@jeydude
Copy link

jeydude commented Apr 12, 2021

We are getting push notification from beta version of Android. and iOS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend LAMP-server, LAMP-worker, and LAMP-app-gateway bug Something isn't working NO ETA No "days of effort required" assigned yet
Projects
None yet
Development

No branches or pull requests

5 participants