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

Webhooks not loading from MySQL driver (maybe all SQL drivers) #133

Closed
stayallive opened this issue Nov 8, 2021 · 4 comments · Fixed by #134
Closed

Webhooks not loading from MySQL driver (maybe all SQL drivers) #133

stayallive opened this issue Nov 8, 2021 · 4 comments · Fixed by #134
Labels
goal:fix Something isn't working

Comments

@stayallive
Copy link
Collaborator

stayallive commented Nov 8, 2021

I have this row in my MySQL database:

name id key secret max_connections enable_client_messages enabled max_backend_events_per_sec max_client_events_per_sec max_read_req_per_sec webhooks
[redacted] [redacted] [redacted] [redacted] -1 0 1 -1 -1 -1 [{"url": "[redacted]", "event_types": ["channel_vacated"]}]

But when running DEBUG=1 pws-server start I see the following:

👨‍🔬 New connection:
{
  ws: uWS.WebSocket {
    ip: '127.0.0.1',
    ip2: '',
    appKey: '[redacted]'
  }
}
✈ Sent message to client:
{
  ws: uWS.WebSocket {
    ip: '127.0.0.1',
    ip2: '',
    appKey: '[redacted]',
    sendJson: [Function (anonymous)],
    id: '[redacted]',
    subscribedChannels: Set(0) {},
    presence: Map(0) {},
    app: App {
      id: '[redacted]',
      key: '[redacted]',
      secret: '[redacted]',
      maxConnections: -1,
      enableClientMessages: 0,
      enabled: 1,
      maxBackendEventsPerSecond: -1,
      maxClientEventsPerSecond: -1,
      maxReadRequestsPerSecond: -1,
      webhooks: []
    },
    timeout: Timeout {
      _idleTimeout: 120000,
      _idlePrev: [TimersList],
      _idleNext: [TimersList],
      _idleStart: 7392,
      _onTimeout: [Function (anonymous)],
      _timerArgs: undefined,
      _repeat: null,
      _destroyed: false,
      [Symbol(refed)]: true,
      [Symbol(kHasPrimitive)]: false,
      [Symbol(asyncId)]: 1885,
      [Symbol(triggerId)]: 0
    }
  },
  data: {
    event: 'pusher:connection_established',
    data: '{"socket_id":"[redacted]","activity_timeout":30}'
  }
}

All data is there except that webhooks is empty, so they don't seem to be loaded from the SQL database.

And webhooks are also not delivered so it doesn't looks to be broken debug output.

I tried restarting the server and clearing Redis before starting the server all to no avail.

Possibly #66 experienced this too.

@rennokki rennokki added the goal:fix Something isn't working label Nov 9, 2021
@rennokki
Copy link
Member

rennokki commented Nov 9, 2021

Usually, the DEBUG=1 would output something like below. Is the appManager.driver set to mysql and the MySQL database credentials configured?

{
  adapter: { driver: 'local', redis: { prefix: '' } },
  appManager: {
    driver: 'array',
    array: {
      apps: [
        {
          id: 'app-id',
          key: 'app-key',
          secret: 'app-secret',
          maxConnections: -1,
          enableClientMessages: false,
          enabled: true,
          maxBackendEventsPerSecond: -1,
          maxClientEventsPerSecond: -1,
          maxReadRequestsPerSecond: -1,
          webhooks: []
        }
      ]
    },
    dynamodb: { table: 'apps', region: 'us-east-1', endpoint: '' },
    mysql: { table: 'apps', version: '8.0' },
    postgres: { table: 'apps', version: '13.3' }
  },
  channelLimits: { maxNameLength: 200 },
  cors: {
    credentials: true,
    origin: [ '*' ],
    methods: [ 'GET', 'POST', 'PUT', 'DELETE', 'OPTIONS' ],
    allowedHeaders: [
      'Origin',
      'Content-Type',
      'X-Auth-Token',
      'X-Requested-With',
      'Accept',
      'Authorization',
      'X-CSRF-TOKEN',
      'XSRF-TOKEN',
      'X-Socket-Id'
    ]
  },
  database: {
    mysql: {
      host: '127.0.0.1',
      port: 3306,
      user: 'root',
      password: 'password',
      database: 'main'
    },
    postgres: {
      host: '127.0.0.1',
      port: 5432,
      user: 'postgres',
      password: 'password',
      database: 'main'
    },
    redis: {
      host: '127.0.0.1',
      port: 6379,
      db: 0,
      username: null,
      password: null,
      keyPrefix: '',
      sentinels: null,
      sentinelPassword: null,
      name: 'mymaster'
    }
  },
  databasePooling: { enabled: false, min: 0, max: 7 },
  debug: 1,
  eventLimits: { maxChannelsAtOnce: 100, maxNameLength: 200, maxPayloadInKb: 100 },
  httpApi: { requestLimitInMb: 100 },
  instance: { process_id: 37716 },
  metrics: {
    enabled: false,
    driver: 'prometheus',
    prometheus: { prefix: 'pws_' }
  },
  port: 6001,
  pathPrefix: '',
  presence: { maxMembersPerChannel: 100, maxMemberSizeInKb: 2 },
  queue: { driver: 'sync', redis: { concurrency: 1 } },
  rateLimiter: { driver: 'local' },
  ssl: { certPath: '', keyPath: '', passphrase: '' }
}

@stayallive
Copy link
Collaborator Author

stayallive commented Nov 9, 2021

Looks like it!

{
  adapter: { driver: 'local', redis: { prefix: '' } },
  appManager: {
    driver: 'mysql',
    array: {
      apps: [
        {
          id: 'app-id',
          key: 'app-key',
          secret: 'app-secret',
          maxConnections: -1,
          enableClientMessages: false,
          enabled: true,
          maxBackendEventsPerSecond: -1,
          maxClientEventsPerSecond: -1,
          maxReadRequestsPerSecond: -1,
          webhooks: []
        }
      ]
    },
    dynamodb: { table: 'apps', region: 'us-east-1', endpoint: '' },
    mysql: { table: 'apps', version: '8.0' },
    postgres: { table: 'apps', version: '13.3' }
  },
  channelLimits: { maxNameLength: 200 },
  cors: {
    credentials: true,
    origin: [ '*' ],
    methods: [ 'GET', 'POST', 'PUT', 'DELETE', 'OPTIONS' ],
    allowedHeaders: [
      'Origin',
      'Content-Type',
      'X-Auth-Token',
      'X-Requested-With',
      'Accept',
      'Authorization',
      'X-CSRF-TOKEN',
      'XSRF-TOKEN',
      'X-Socket-Id'
    ]
  },
  database: {
    mysql: {
      host: '127.0.0.1',
      port: 3306,
      user: '[redacted]',
      password: '[redacted]',
      database: '[redacted]'
    },
    postgres: {
      host: '127.0.0.1',
      port: 5432,
      user: 'postgres',
      password: 'password',
      database: 'main'
    },
    redis: {
      host: '127.0.0.1',
      port: 6379,
      db: 0,
      username: null,
      password: null,
      keyPrefix: '',
      sentinels: null,
      sentinelPassword: null,
      name: 'mymaster'
    }
  },
  databasePooling: { enabled: false, min: 0, max: 7 },
  debug: 1,
  eventLimits: { maxChannelsAtOnce: 100, maxNameLength: 200, maxPayloadInKb: 100 },
  httpApi: { requestLimitInMb: 100 },
  instance: { process_id: 86657 },
  metrics: {
    enabled: false,
    driver: 'prometheus',
    prometheus: { prefix: 'pws_' }
  },
  port: 6001,
  pathPrefix: '',
  presence: { maxMembersPerChannel: 100, maxMemberSizeInKb: 2 },
  queue: { driver: 'redis', redis: { concurrency: 1 } },
  rateLimiter: { driver: 'local' },
  ssl: { certPath: '', keyPath: '', passphrase: '' }
}

All other features do work just fine, I have multiple apps that all connect. It's just the webhooks not working.

@rennokki
Copy link
Member

rennokki commented Nov 9, 2021

Fixed the bug, thanks for testing it out. 👍 Since there are a lot of matrix configurations to test (and this leads to exponential-ish growth of tests for each commit), I try to avoid testing every little combination. Perhaps in the near future, I'll find a better way to automatically test every little error like this one.

@stayallive
Copy link
Collaborator Author

No worries, it's still in the 0.x. I expected a few rough edges 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
goal:fix Something isn't working
Development

Successfully merging a pull request may close this issue.

2 participants