I am trying to build a very simple python3 program using sleekxmpp 1.3.1 that would be able to connect the Firebase Cloud Messaging server. I have a strange Error reading from XML stream
issue with the following code. How can I fix it?
We can see from the console output that STARTTLS is enabled. I found no other way than disable it from the sleekxmpp source code, but it does not solved the bug.
The first message sent seems valid according to the google documentation, still the "error reading from xml stream" appears.
The python code
FCM_SERVER_URL = "fcm-xmpp.googleapis.com"
FCM_SERVER_PORT = 5236
FCM_SECRET = "XXXXXXX"
FCM_JID = "[email protected]"
import logging, socket
from sleekxmpp.clientxmpp import ClientXMPP
class ClientComponent(ClientXMPP):
def __init__(self):
ClientXMPP.__init__(self, FCM_JID, FCM_SECRET)
self.auto_reconnect = False
server_ip = socket.gethostbyname(FCM_SERVER_URL)
if self.connect((server_ip, FCM_SERVER_PORT), use_tls = True, reattempt = False):
self.process(block=True)
logging.basicConfig(level=logging.DEBUG, format='%(levelname)7s %(module)12s:%(lineno)-4s %(message)s')
ClientComponent()
The console output
DEBUG base:328 Loaded Plugin: RFC 6120: Stream Feature: STARTTLS
DEBUG base:328 Loaded Plugin: RFC 6120: Stream Feature: Resource Binding
DEBUG base:328 Loaded Plugin: RFC 3920: Stream Feature: Start Session
DEBUG base:328 Loaded Plugin: RFC 6121: Stream Feature: Roster Versioning
DEBUG base:328 Loaded Plugin: RFC 6121: Stream Feature: Subscription Pre-Approval
DEBUG base:328 Loaded Plugin: RFC 6120: Stream Feature: SASL
DEBUG xmlstream:546 Connecting to 66.102.1.188:5236
DEBUG xmlstream:1162 Event triggered: connected
DEBUG statemachine:118 ==== TRANSITION disconnected -> connected
DEBUG xmlstream:1444 Starting HANDLER THREAD
DEBUG xmlstream:1662 Loading event runner
DEBUG xmlstream:1309 SEND (IMMED): <stream:stream to="gcm.googleapis.com" xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" xml:lang='en' version="1.0">
ERROR xmlstream:1492 Error reading from XML stream.
DEBUG xmlstream:1162 Event triggered: session_end
DEBUG xmlstream:1309 SEND (IMMED): </stream:stream>
DEBUG xmlstream:1162 Event triggered: socket_error
WARNING xmlstream:1342 Failed to send b'</stream:stream>'
DEBUG xmlstream:1162 Event triggered: session_end
DEBUG xmlstream:1397 Waiting for 3 threads to exit.
DEBUG xmlstream:1375 Stopped event runner thread. 2 threads remain.
DEBUG xmlstream:1375 Stopped send thread. 1 threads remain.
DEBUG scheduler:200 Quitting Scheduler thread
DEBUG xmlstream:1375 Stopped scheduler thread. 0 threads remain.
DEBUG xmlstream:1162 Event triggered: socket_error
DEBUG xmlstream:1162 Event triggered: disconnected
DEBUG statemachine:118 ==== TRANSITION connected -> disconnected
INFO xmlstream:720 Waiting for </stream:stream> from server
DEBUG xmlstream:1162 Event triggered: socket_error
DEBUG xmlstream:1162 Event triggered: disconnected
DEBUG statemachine:118 ==== TRANSITION disconnected -> disconnected
Copyright Notice:Content Author:「azmeuk」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/38014495/error-trying-to-connect-the-fcm-ccs-server-with-sleekxmpp