googlearchive / web-push-encryption

[Deprecated] Encryption Utilities for Web Push protocol
Apache License 2.0
84 stars 23 forks source link

MessageTooBig #57

Closed FallDi closed 7 years ago

FallDi commented 8 years ago

Also i got such response from GCM

{ statusCode: 200,
  statusMessage: 'OK',
  body: '{"multicast_id":6777736059144782845,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"MessageTooBig"}]}' }

For simple payload - "Hello". Encoded payload is too big, any way to resolve it? I understand that encrypted payload is big, but how to pass normal data in this case? But sometimes for same payload it works...

samthor commented 7 years ago

The relevant specifications (and GCM for older Google clients) all specify that the maximum size is 4096 bytes (and that in practice it should be slightly lower due to encoding).

Are you sure your payload is <4kb after encryption?

FallDi commented 7 years ago

It problem can be closed. We use base64 url encode for raw_data. It was wrong. Classic base64 help resolve it issue. Thanks.

body = JSON.stringify({
      "registration_ids": ["cIKD0Ykm2ZI:APA91bG-OP...."],
      "raw_data": payload.ciphertext.toString('base64')
    });