Git Product home page Git Product logo

firebase-cloud-messaging-fcm-xmpp's Introduction

๐Ÿ‘‹ Hello! I'm Baudev.

  • Young french engineer living in Paris
  • ๐Ÿš€ Passionate about technology

๐Ÿšง Some projects

GDPR Compliance Analyzer

Tool to check the compliance of a website with the GDPR (General Data Protection Regulation) regarding its use of cookies.

TypeScript NestJS Postgres Heroku

Firebase Cloud Messaging XMPP Server

Library to create a PHP server to connect to Google Firebase Cloud Messaging using XMPP protocol.

PHP Firebase

โ›๏ธ Some contributions

remixz/messenger-bot: A Node client for the Facebook Messenger Platform
microsoft/TSS.MSR: The TPM Software Stack from Microsoft Research
IndraGunawan/api-rate-limit-bundle: Rate limits protection for api-platform resources
api-platform/docs: Create REST and GraphQL APIs, scaffold Jamstack webapps, stream changes in real-time.
JairajJangle/motionEye_app_HomeSurveillanceSystem: Home Surveillance System, available on Google Play Store.

firebase-cloud-messaging-fcm-xmpp's People

Contributors

baudev avatar caveman99 avatar sourc7 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

firebase-cloud-messaging-fcm-xmpp's Issues

Unit tests

I don't have a lot of time right now, but it would be important to work on unit tests. They demonstrate the quality of a code.

Is anyone interested?
Could someone help me with their achievements?

Script randomly get stuck in an infinite loop

Recently my script got stuck in a loop, printing out to log many rows like this:

=== Read 0 bytes === {{timestamp}} ===

When it happens the script don't receive FCM messages from the Google server anymore and the log get flooded with these Read 0 bytes messages at a rate of hundreds per seconds, like it got stuck in a loop. The only way to recover is to kill the process and restart.

I started seeing this behavior in the 1.0.1 version, so I suspect that some change related to another recent issue could be involved. I run this server for months and never seen that in 1.0.0, but already happened three times in the last week with 1.0.1.

onLoop() method not called each X microsonds

What is the bug?

This issue is concerning a bug with the onLoop() method.

The way of handling the onLoop timer is not correct. Indeed, it uses the timeout of the connection.
Then, each message received reset the timer.

How to reproduce this bug?

// enable the onLoop method
$test->enableOnLoopMethod(5 * 1000 * 1000); //onLoop should be called each 5 seconds
  1. Launch the script
  2. Wait 3 seconds and send a message from the client to the server
  3. The onLoop() method will be called only 5 seconds after the message has been received

What's happen when server script is down ?

Hi,
I use your program successfully.
A question: if the script falls, it does not recover all messages received by FCM when it is restarted ! Is there a solution ?
Thank you for your work,

Will this suite my use?

I need to send notification to client devices when new orders are received. Currently using FCM over HTTP. I need confirmations on delivery and respond if delivery fails with x amount of time, say if it ain't delivered within 5 minutes do X.

I don't want to mess too much with existing code on my server for now, with this library could i just run it in the background with something like nohup, and deal with failures there, with the current http sending method on my server just add the delivery receipts flag? or does the data payload have to be sent with the library?

110 Connection timed out

Hello,

I have a problem. The script works well on my local machine with PHP 7.3.7 but I get a timeout on my server with PHP 7.3.9.
Here is the error:

=== Connecting to fcm-xmpp.googleapis.com:5235 at 2019-09-05T15:58:17+0000 === 2019-09-05T15:58:17+0000 === PHP Warning: stream_socket_client(): unable to connect to tls://fcm-xmpp.googleapis.com:5235 (Connection timed out) in /var/www/vhosts/xxxx.com/httpdocs/api-test/vendor/baudev/fcm-xmpp/src/Core.php on line 118

Do you think it's a PHP problem or a configuration problem at firebase?

Many thanks,

Best regards,

Error in incoming FCM messages parsing

Recently I experienced a parsing error of incoming FCM messages, it seems that it merged two distinct messages into one, screwing up the received data. Here's the log from the event (I obscured some sensitive data with x and tagged each read fragment to easily reference in the following explanation):

(fragment A) === Read 1179 bytes === 2019-04-18T22:44:10+0200 ===
<message to="[email protected]" from="[email protected]" type="normal"><gcm xmlns="google:mobile:data">{"data":{"b":"90-","s":"1555620234609;0;1555603200;com.whatsapp;20745|1555620234609;0;1555592400;com.motorola.camera2;11997|1555620234609;0;1555610400;SCREEN;1861856|1555620234609;0;1555549200;com.facebook.katana;2802|1555620234609;0;1555099200;SCREEN;233469|1555620234609;0;1555344000;com.android.chrome;106698|1555620234609;0;1555236000;com.google.android.youtube;1978654|1555620234609;0;1555578000;SCREEN;207177|1555620234609;0;1555178400;com.google.android.gm;30267|1555620234609;0;1555254000;SCREEN;304379|1555620234609;1;1555297200;com.google.android.gm;18098|1555620234609;0;1555444800;com.whatsapp;372120|1555620234609;0;1555092000;SCREEN;517674|1555620234609;0;1555344000;com.android.dialer;367701|1555620234609;0;1555437600;com.android.dialer;6339|1555620234609;1;1555210800;com.google.android.gm;274781|1555620234609;0;1555088400;com.whatsapp;61535|1555620234609;0;1555207200;SCREEN;646926|1555620234609;0;1555426800;com.facebook.katana;2186|1555620234609;0;1555164000;com.android.chrome;1925002|1555620234609;0;1555513200;com.android.dialer;
=== Message is fragmented because footer is missing. === 2019-04-18T22:44:10+0200 ===
=== Parsing message.. === 2019-04-18T22:44:10+0200 ===

(fragment B) === Read 611 bytes === 2019-04-18T22:44:10+0200 ===
6205|1555620234609;1;1555038000;com.android.dialer;2619646|1555620234609;0;1555336800;com.motorola.camera2;28588|1555620234609;0;1555322400;com.google.android.youtube;794373|1555620234609;0;1555272000;SCREEN;471353|1555620234609;0;1555358400;SCREEN;638027|1555620234609;0;1555120800;com.facebook.katana;1559063|1555620234609;0;1555160400;com.google.android.youtube;684137|1555620234609;0;1555149600;com.whatsapp;78854|1555620234609;0;1555192800;com.whatsapp;435216|1555620234609;0;1555502400;com.android.chrome;127568|1555620234609;0;1555160400;SCREEN;1685082|1555620234609;0;1555156800;com.facebook.katana;1870

(fragment C) === Read 1179 bytes === 2019-04-18T22:44:10+0200 ===
|1555620234609;0;1555419600;com.android.chrome;57229|1555620234609;0;1555135200;com.whatsapp;285346|1555620234609;0;1555495200;com.whatsapp;421926|1555620234609;0;1555603200;com.android.dialer;2579648|1555620234609;0;1555257600;SCREEN;432235|1555620234609;0;1555070400;SCREEN;425691|1555620234609;0;1555333200;com.whatsapp;57051|1555620234609;0;1555318800;com.facebook.katana;32503|1555620234609;0;1555506000;com.facebook.katana;19781|1555620234609;0;1555592400;SCREEN;862028|1555620234609;0;1555592400;com.android.chrome;139706|1555620234609;0;1555174800;SCREEN;2596621|1555620234609;0;1555351200;com.facebook.katana;10262|1555620234609;0;1555282800;SCREEN;339981|1555620234609;0;1555268400;SCREEN;1428175|1555620234609;3;1554087600;com.android.dialer;19299715|1555620234609;0;1555315200;SCREEN;22694|1555620234609;0;1555534800;com.facebook.katana;1079977|1555620234609;0;1555329600;SCREEN;234441|1555620234609;0;1555189200;SCREEN;721670|1555620234609;0;1555329600;com.whatsapp;1742|1555620234609;0;1555390800;com.android.dialer;2184|1555620234609;0;1555192800;com.google.android.gm;97958|1555620234609;0;1555282800;com.facebook.katana;29178|1555620234609;0;1555077600;com.whats

(fragment D) === Read 1179 bytes === 2019-04-18T22:44:10+0200 ===
app;29194|1555620234609;0;1555261200;com.facebook.katana;1732755|1555620234609;0;1555408800;com.android.dialer;40408|1555620234609;0;1555066800;SCREEN;285569|1555620234609;0;1555606800;com.android.dialer;457281|1555620234609;0;1555491600;com.whatsapp;63375|1555620234609;0;1555336800;com.android.dialer;2082|1555620234609;0;1555131600;com.whatsapp;96236|1555620234609;0;1555599600;com.android.dialer;104688|1555620234609;0;1555372800;com.android.dialer;728442|1555620234609;0;1555495200;com.android.chrome;183371|1555620234609;2;1554606000;com.motorola.camera2;215108|1555620234609;0;1555344000;com.whatsapp;292079|1555620234609;0;1555606800;com.whatsapp;965566|1555620234609;0;1555315200;com.android.chrome;2084|1555620234609;0;1555196400;SCREEN;2006413|1555620234609;0;1555138800;com.google.android.youtube;465200|1555620234609;0;1555603200;com.whatsweb.app;448730|1555620234609;0;1555448400;SCREEN;92093|1555620234609;0;1555441200;com.android.dialer;102128|1555620234609;0;1555286400;com.google.android.gm;255332|1555620234609;0;1555524000;SCREEN;313223|1555620234609;0;1555599600;com.facebook.katana;7267|1555620234609;0;1555401600;com.google.android.youtube;724|155562023460

(fragment E) === Read 1179 bytes === 2019-04-18T22:44:10+0200 ===
9;1;1555038000;com.google.android.gm;264526","d":"xxxxxxxxxxxxxxx","t":"t"},"time_to_live":86400,"from":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","message_id":"S15556202478973","category":"com.xxxxxxxxxxxxxxxxxxxxx"}</gcm></message><message to="[email protected]" from="[email protected]" type="normal"><gcm xmlns="google:mobile:data">{"data":{"b":"90-","s":"1555620234609;0;1555171200;com.android.chrome;1141732|1555620234609;1;1555297200;com.google.android.youtube;794373|1555620234609;2;1554606000;com.android.chrome;6016743|1555620234609;0;1555412400;com.google.android.youtube;332522|1555620234609;0;1555066800;com.whatsapp;165104|1555620234609;1;1555556400;com.facebook.katana;4668860|1555620234609;0;1555257600;com.android.dialer;55717|1555620234609;1;1555383600;com.google.android.deskclock;2864874|1555620234609;1;1555383600;com.google.android.youtube;1876153|1555620234609;0;1555293600;SCREEN;3599|1555620234609;1;1555556400;com.google.android.youtube;2585808|1555620234609;0;1555401600;com.whatsapp;91751|1555620234609;0;1555416000;
=== Message is not fragmented. === 2019-04-18T22:44:10+0200 ===

(fragment F) === Read 354 bytes === 2019-04-18T22:44:10+0200 ===
SCREEN;32476|1555620234609;0;1555210800;SCREEN;81794","d":"xxxxxxxxxxxxxxx","t":"t"},"time_to_live":86400,"from":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","message_id":"S15556202482837","category":"com.xxxxxxxxxxxxxxxxxxxxx"}</gcm></message>
=== Message parsed succesfully. === 2019-04-18T22:44:10+0200 ===
=== Sent 277 bytes === 2019-04-18T22:44:10+0200 ===
<message id=""><gcm xmlns="google:mobile:data">{"to":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","message_id":"S15556202482837","message_type":"ack"}</gcm></message>

As you can see in the fragment E there is a closing message footer followed by a new message header, and that new message is closed in the fragment F. So I expect to get these two messages:

message 1: from concatenation of fragments A + B + C + D + (part of) E
message 2: from concatenation of fragments (part of) E + F

Instead, in the onReceiveMessage i get message 1 from concatenation of fragments A + B + C + D + F, that's obviously wrong! I don't even know what the content of fragment E would have generated, since my script crashed on receiving message 1 because the contained data were corrupted by the wrong concatenation.

I hope I well described what's happening here, let me know if I can provide any other useful information.

Installation Error

image
As image above, I can't install the package.
My environment is:
PHP version: 7.0-cli
Ubuntu version: 16.04

Any suggestion?
Thank you!!

About server and database

Do you mean after I install your fcm-xmpp, my computer will run as a server and also as a database?
In my case, I have two phones and one laptop.
I want mobile phone A to upstream the message to the laptop, then mobile phone B will downstream the message from the laptop.
Should I set another device as database?
Thank you!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.