Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Can't establish connection #40

Closed
barnettech opened this Issue · 14 comments

2 participants

@barnettech

Here is my log:

<body rid='7905790180136' xmlns='http://jabber.org/protocol/httpbind' type='terminate'><presence xmlns='jabber:client' type='unavailable'/></body>
strophe.js?t (line 2188)
<body xmlns='http://jabber.org/protocol/httpbind' condition='item-not-found' message='Invalid session ID' type='terminate'/>

I connect fine with the same code to a punjab server which is a free testing service provided by Jack Motiff.

Connecting to this free testing server http://bosh.metajack.im:5280/xmpp-httpbind' I have no problems. Any help would be great thank you.

@dhruvbird
Owner

What URL are you using to connect to the bosh server?

Try running the BOSH server with --logging=TRACE and check the log (or stdout) for any messages being printed when you connect. If you don't see anything, you're probably using the wrong URL.

@barnettech

Here are my logs it is hitting the server: http://pastebin.com/Qpd3e1Pp

+-----------------------------------------------------------------------------------------------------------------------------------------+
| Starting BOSH server 'v0.6.1' on 'http://drupaltest3.babson.edu:5280/^\/http-bind(\/+)?$/' at 'Thu Jul 05 2012 07:56:35 GMT-0400 (EDT)' |
+-----------------------------------------------------------------------------------------------------------------------------------------+
+----------------------------------------------------------------------------------------------------------------------+
| Starting WEBSOCKET server 'v0.6.1' on ws://drupaltest3.babson.edu:5280' at 'Thu Jul 05 2012 07:56:35 GMT-0400 (EDT)' |
+----------------------------------------------------------------------------------------------------------------------+
[2012-07-05 07:57:27.761] [INFO] [xmpp-proxy.js] - e051e84d-c9da-4764-aaef-f15379675208 482c30bf-7569-4475-9d68-43400d369f0b _on_close error: false
[2012-07-05 07:57:27.762] [INFO] [xmpp-proxy.js] - e051e84d-c9da-4764-aaef-f15379675208 482c30bf-7569-4475-9d68-43400d369f0b _close_connection error: null
[2012-07-05 07:57:27.762] [INFO] [xmpp-proxy-connector.js] - e051e84d-c9da-4764-aaef-f15379675208 482c30bf-7569-4475-9d68-43400d369f0b _on_xmpp_proxy_close - terminate stream
[2012-07-05 07:57:27.763] [INFO] [session.js] - e051e84d-c9da-4764-aaef-f15379675208 send_terminate_response - ro: false, condition: no-condition
[2012-07-05 07:57:49.327] [INFO] [xmpp-proxy.js] - 1647621b-9f0c-42ae-9dd0-f3329bfe97d0 212135dc-2a9e-4f87-9ccb-6f6f959781b6 _on_close error: false
[2012-07-05 07:57:49.328] [INFO] [xmpp-proxy.js] - 1647621b-9f0c-42ae-9dd0-f3329bfe97d0 212135dc-2a9e-4f87-9ccb-6f6f959781b6 _close_connection error: null
[2012-07-05 07:57:49.328] [INFO] [xmpp-proxy-connector.js] - 1647621b-9f0c-42ae-9dd0-f3329bfe97d0 212135dc-2a9e-4f87-9ccb-6f6f959781b6 _on_xmpp_proxy_close - terminate stream
[2012-07-05 07:57:49.329] [INFO] [session.js] - 1647621b-9f0c-42ae-9dd0-f3329bfe97d0 send_terminate_response - ro: false, condition: no-condition
[2012-07-05 08:28:05.482] [INFO] [xmpp-proxy.js] - db0ac931-21ac-4626-91e6-84b6026c0a42 03ef57c5-fd5a-43a2-8970-c9b1822ac7fe _on_close error: false
[2012-07-05 08:28:05.482] [INFO] [xmpp-proxy.js] - db0ac931-21ac-4626-91e6-84b6026c0a42 03ef57c5-fd5a-43a2-8970-c9b1822ac7fe _close_connection error: null
[2012-07-05 08:28:05.482] [INFO] [xmpp-proxy-connector.js] - db0ac931-21ac-4626-91e6-84b6026c0a42 03ef57c5-fd5a-43a2-8970-c9b1822ac7fe _on_xmpp_proxy_close - terminate stream
[2012-07-05 08:28:05.483] [INFO] [session.js] - db0ac931-21ac-4626-91e6-84b6026c0a42 send_terminate_response - ro: false, condition: no-condition
+-----------------------------------------------------------------------------------------------------------------------------------------+
| Starting BOSH server 'v0.6.1' on 'http://drupaltest3.babson.edu:5280/^\/http-bind(\/+)?$/' at 'Thu Jul 05 2012 12:17:04 GMT-0400 (EDT)' |
+-----------------------------------------------------------------------------------------------------------------------------------------+
[2012-07-05 12:17:04.733] [TRACE] [main.js] - Starting the BOSH server
+----------------------------------------------------------------------------------------------------------------------+
| Starting WEBSOCKET server 'v0.6.1' on ws://drupaltest3.babson.edu:5280' at 'Thu Jul 05 2012 12:17:04 GMT-0400 (EDT)' |
+----------------------------------------------------------------------------------------------------------------------+
[2012-07-05 12:17:34.139] [TRACE] [http-server.js] - Processing POST request at location: /http-bind
[2012-07-05 12:17:34.140] [DEBUG] [http-server.js] - RECD: <body rid="14000053460000" xmlns="http://jabber.org/protocol/httpbind" to="babso... [143 more characters]
[2012-07-05 12:17:34.141] [TRACE] [bosh.js] - Processing Request
[2012-07-05 12:17:34.141] [TRACE] [bosh.js] - Session Creation
[2012-07-05 12:17:34.142] [TRACE] [session.js] - 91ca672c-53d2-4d6e-964d-42b54f617478 reset_inactivity_timeout - 80 sec
[2012-07-05 12:17:34.142] [TRACE] [session.js] - 91ca672c-53d2-4d6e-964d-42b54f617478 add_held_http_connection - now holding 1 res obj
[2012-07-05 12:17:34.142] [TRACE] [xmpp-proxy-connector.js] - 91ca672c-53d2-4d6e-964d-42b54f617478 56f0ebc3-0d18-4f10-88b1-69f55a29566a stream_add
[2012-07-05 12:17:34.143] [TRACE] [lookup-service.js] - try_connect_SRV_lookup - babson.edu
[2012-07-05 12:17:34.143] [TRACE] [session.js] - 91ca672c-53d2-4d6e-964d-42b54f617478 56f0ebc3-0d18-4f10-88b1-69f55a29566a enqueue_bosh_response
[2012-07-05 12:17:34.251] [TRACE] [lookup-service.js] - Connection to babson.edu succeeded
[2012-07-05 12:17:34.252] [TRACE] [xmpp-proxy.js] - 91ca672c-53d2-4d6e-964d-42b54f617478 56f0ebc3-0d18-4f10-88b1-69f55a29566a connected
[2012-07-05 12:17:34.252] [TRACE] [xmpp-proxy.js] - 91ca672c-53d2-4d6e-964d-42b54f617478 56f0ebc3-0d18-4f10-88b1-69f55a29566a Sent: <stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:cli... [35 more characters]
[2012-07-05 12:17:34.252] [TRACE] [xmpp-proxy-connector.js] - 91ca672c-53d2-4d6e-964d-42b54f617478 56f0ebc3-0d18-4f10-88b1-69f55a29566a _on_xmpp_proxy_connected - connected
[2012-07-05 12:17:34.252] [TRACE] [bosh.js] - 91ca672c-53d2-4d6e-964d-42b54f617478 56f0ebc3-0d18-4f10-88b1-69f55a29566a stream-added
[2012-07-05 12:17:34.357] [DEBUG] [xmpp-proxy.js] - 91ca672c-53d2-4d6e-964d-42b54f617478 56f0ebc3-0d18-4f10-88b1-69f55a29566a _on_data RECD 139 bytes
[2012-07-05 12:17:34.358] [TRACE] [xmpp-proxy.js] - 91ca672c-53d2-4d6e-964d-42b54f617478 56f0ebc3-0d18-4f10-88b1-69f55a29566a _on_stream_start: stream started
[2012-07-05 12:17:34.358] [DEBUG] [xmpp-proxy.js] - 91ca672c-53d2-4d6e-964d-42b54f617478 56f0ebc3-0d18-4f10-88b1-69f55a29566a _on_data RECD 241 bytes
[2012-07-05 12:17:34.359] [TRACE] [xmpp-proxy.js] - 91ca672c-53d2-4d6e-964d-42b54f617478 56f0ebc3-0d18-4f10-88b1-69f55a29566a _on_stanza parsed: <stream:features><starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"><required/></... [161 more characters]
[2012-07-05 12:17:34.359] [TRACE] [xmpp-proxy.js] - 91ca672c-53d2-4d6e-964d-42b54f617478 56f0ebc3-0d18-4f10-88b1-69f55a29566a _on_stanza starttls requested
[2012-07-05 12:17:34.359] [TRACE] [xmpp-proxy.js] - 91ca672c-53d2-4d6e-964d-42b54f617478 56f0ebc3-0d18-4f10-88b1-69f55a29566a Writing out starttls
[2012-07-05 12:17:34.359] [TRACE] [xmpp-proxy.js] - 91ca672c-53d2-4d6e-964d-42b54f617478 56f0ebc3-0d18-4f10-88b1-69f55a29566a Sent: <starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"/>
[2012-07-05 12:17:34.466] [DEBUG] [xmpp-proxy.js] - 91ca672c-53d2-4d6e-964d-42b54f617478 56f0ebc3-0d18-4f10-88b1-69f55a29566a _on_data RECD 50 bytes
[2012-07-05 12:17:34.466] [TRACE] [xmpp-proxy.js] - 91ca672c-53d2-4d6e-964d-42b54f617478 56f0ebc3-0d18-4f10-88b1-69f55a29566a _on_stanza parsed: <proceed xmlns="urn:ietf:params:xml:ns:xmpp-tls"/>
[2012-07-05 12:17:34.466] [TRACE] [xmpp-proxy.js] - 91ca672c-53d2-4d6e-964d-42b54f617478 56f0ebc3-0d18-4f10-88b1-69f55a29566a _starttls
[2012-07-05 12:17:34.702] [TRACE] [xmpp-proxy.js] - 91ca672c-53d2-4d6e-964d-42b54f617478 56f0ebc3-0d18-4f10-88b1-69f55a29566a _starttls - restart the stream
[2012-07-05 12:17:34.702] [TRACE] [xmpp-proxy.js] - 91ca672c-53d2-4d6e-964d-42b54f617478 56f0ebc3-0d18-4f10-88b1-69f55a29566a Sent: <stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:cli... [35 more characters]
[2012-07-05 12:17:34.808] [DEBUG] [xmpp-proxy.js] - 91ca672c-53d2-4d6e-964d-42b54f617478 56f0ebc3-0d18-4f10-88b1-69f55a29566a _on_data RECD 139 bytes
[2012-07-05 12:17:34.808] [TRACE] [xmpp-proxy.js] - 91ca672c-53d2-4d6e-964d-42b54f617478 56f0ebc3-0d18-4f10-88b1-69f55a29566a _on_stream_restart: stream restarted
[2012-07-05 12:17:34.809] [DEBUG] [xmpp-proxy.js] - 91ca672c-53d2-4d6e-964d-42b54f617478 56f0ebc3-0d18-4f10-88b1-69f55a29566a _on_data RECD 197 bytes
[2012-07-05 12:17:34.809] [TRACE] [xmpp-proxy.js] - 91ca672c-53d2-4d6e-964d-42b54f617478 56f0ebc3-0d18-4f10-88b1-69f55a29566a _on_stanza parsed: <stream:features><mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism... [117 more characters]
[2012-07-05 12:17:34.809] [TRACE] [xmpp-proxy-connector.js] - 91ca672c-53d2-4d6e-964d-42b54f617478 56f0ebc3-0d18-4f10-88b1-69f55a29566a _on_stanza_received
[2012-07-05 12:17:34.810] [TRACE] [bosh.js] - 91ca672c-53d2-4d6e-964d-42b54f617478 56f0ebc3-0d18-4f10-88b1-69f55a29566a response: <stream:features version="1.0" xmlns:stream="http://etherx.jabber.org/streams" x... [201 more characters]
[2012-07-05 12:17:34.810] [TRACE] [session.js] - 91ca672c-53d2-4d6e-964d-42b54f617478 56f0ebc3-0d18-4f10-88b1-69f55a29566a enqueue_stanza
[2012-07-05 12:17:34.810] [TRACE] [session.js] - 91ca672c-53d2-4d6e-964d-42b54f617478 send_pending_responses - pending.length: 0, Holding 1 response objects
[2012-07-05 12:17:34.810] [TRACE] [session.js] - 91ca672c-53d2-4d6e-964d-42b54f617478 _stitch_new_response - #streams: 1, next_stream: 0
[2012-07-05 12:17:34.810] [TRACE] [session.js] - 91ca672c-53d2-4d6e-964d-42b54f617478 56f0ebc3-0d18-4f10-88b1-69f55a29566a _stitch_response_for_stream - stitched
[2012-07-05 12:17:34.810] [TRACE] [session.js] - 91ca672c-53d2-4d6e-964d-42b54f617478 get_response_object - return ro with rid: 14000053460000
[2012-07-05 12:17:34.810] [TRACE] [session.js] - 91ca672c-53d2-4d6e-964d-42b54f617478 get_response_object - holding 0 ro
[2012-07-05 12:17:34.810] [TRACE] [session.js] - 91ca672c-53d2-4d6e-964d-42b54f617478 send_pending_responses - ro: true, pending_stitched_responses: 1 - sending
[2012-07-05 12:17:34.811] [TRACE] [session.js] - 91ca672c-53d2-4d6e-964d-42b54f617478 _send_no_requeue::ro: true
[2012-07-05 12:17:34.811] [TRACE] [session.js] - 91ca672c-53d2-4d6e-964d-42b54f617478 _send_no_requeue::ro.rid: 14000053460000, this.rid: 14000053460000
[2012-07-05 12:17:34.812] [DEBUG] [response.js] - 91ca672c-53d2-4d6e-964d-42b54f617478 SENT(14000053460000): <body xmlns="http://jabber.org/protocol/httpbind" stream="56f0ebc3-0d18-4f10-88b... [534 more characters]
[2012-07-05 12:17:34.862] [TRACE] [http-server.js] - Processing POST request at location: /http-bind
[2012-07-05 12:17:34.863] [DEBUG] [http-server.js] - RECD: <body rid="14000053460001" xmlns="http://jabber.org/protocol/httpbind" sid=""><a... [129 more characters]
[2012-07-05 12:17:34.863] [TRACE] [bosh.js] - Processing Request
[2012-07-05 12:17:34.863] [TRACE] [bosh.js] - No_Session_ID Invalid Session
[2012-07-05 12:17:34.863] [TRACE] [session.js] - Sending invalid sid
[2012-07-05 12:17:34.864] [DEBUG] [response.js] - invalid-sid SENT(null): <body xmlns="http://jabber.org/protocol/httpbind" condition="item-not-found" mes... [44 more characters]
[2012-07-05 12:17:34.883] [TRACE] [http-server.js] - Processing POST request at location: /http-bind
[2012-07-05 12:17:34.883] [DEBUG] [http-server.js] - RECD: <body rid="14000053460002" xmlns="http://jabber.org/protocol/httpbind" sid="" to... [77 more characters]
[2012-07-05 12:17:34.885] [TRACE] [bosh.js] - Processing Request
[2012-07-05 12:17:34.885] [TRACE] [bosh.js] - No_Session_ID Invalid Session
[2012-07-05 12:17:34.885] [TRACE] [session.js] - Sending invalid sid
[2012-07-05 12:17:34.886] [DEBUG] [response.js] - invalid-sid SENT(null): <body xmlns="http://jabber.org/protocol/httpbind" condition="item-not-found" mes... [44 more characters]
[2012-07-05 12:17:34.892] [TRACE] [http-server.js] - Processing POST request at location: /http-bind
[2012-07-05 12:17:34.892] [DEBUG] [http-server.js] - RECD: <body rid="14000053460003" xmlns="http://jabber.org/protocol/httpbind" sid=""><i... [113 more characters]
[2012-07-05 12:17:34.893] [TRACE] [bosh.js] - Processing Request
[2012-07-05 12:17:34.893] [TRACE] [bosh.js] - No_Session_ID Invalid Session
[2012-07-05 12:17:34.893] [TRACE] [session.js] - Sending invalid sid
[2012-07-05 12:17:34.893] [DEBUG] [response.js] - invalid-sid SENT(null): <body xmlns="http://jabber.org/protocol/httpbind" condition="item-not-found" mes... [44 more characters]
[2012-07-05 12:17:34.900] [TRACE] [http-server.js] - Processing POST request at location: /http-bind
[2012-07-05 12:17:34.900] [DEBUG] [http-server.js] - RECD: <body rid="14000053460004" xmlns="http://jabber.org/protocol/httpbind" sid=""><i... [122 more characters]
[2012-07-05 12:17:34.900] [TRACE] [bosh.js] - Processing Request
[2012-07-05 12:17:34.900] [TRACE] [bosh.js] - No_Session_ID Invalid Session
[2012-07-05 12:17:34.900] [TRACE] [session.js] - Sending invalid sid
[2012-07-05 12:17:34.901] [DEBUG] [response.js] - invalid-sid SENT(null): <body xmlns="http://jabber.org/protocol/httpbind" condition="item-not-found" mes... [44 more characters]
[2012-07-05 12:17:35.075] [TRACE] [http-server.js] - Processing POST request at location: /http-bind
[2012-07-05 12:17:35.076] [DEBUG] [http-server.js] - RECD: <body rid="7905790180137" xmlns="http://jabber.org/protocol/httpbind"><iq type="... [191 more characters]
[2012-07-05 12:17:35.076] [TRACE] [bosh.js] - Processing Request
[2012-07-05 12:17:35.076] [TRACE] [bosh.js] - No_Session_ID Invalid Session
[2012-07-05 12:17:35.076] [TRACE] [session.js] - Sending invalid sid
[2012-07-05 12:17:35.076] [DEBUG] [response.js] - invalid-sid SENT(null): <body xmlns="http://jabber.org/protocol/httpbind" condition="item-not-found" mes... [44 more characters]
[2012-07-05 12:17:35.096] [TRACE] [http-server.js] - Processing POST request at location: /http-bind
[2012-07-05 12:17:35.096] [DEBUG] [http-server.js] - RECD: <body rid="7905790180138" xmlns="http://jabber.org/protocol/httpbind" type="term... [66 more characters]
[2012-07-05 12:17:35.096] [TRACE] [bosh.js] - Processing Request
[2012-07-05 12:17:35.096] [TRACE] [bosh.js] - No_Session_ID Invalid Session
[2012-07-05 12:17:35.096] [TRACE] [session.js] - Sending invalid sid
[2012-07-05 12:17:35.096] [DEBUG] [response.js] - invalid-sid SENT(null): <body xmlns="http://jabber.org/protocol/httpbind" condition="item-not-found" mes... [44 more characters]
[2012-07-05 12:17:54.358] [INFO] [xmpp-proxy.js] - 91ca672c-53d2-4d6e-964d-42b54f617478 56f0ebc3-0d18-4f10-88b1-69f55a29566a _on_close error: false
[2012-07-05 12:17:54.358] [INFO] [xmpp-proxy.js] - 91ca672c-53d2-4d6e-964d-42b54f617478 56f0ebc3-0d18-4f10-88b1-69f55a29566a _close_connection error: null
[2012-07-05 12:17:54.359] [INFO] [xmpp-proxy-connector.js] - 91ca672c-53d2-4d6e-964d-42b54f617478 56f0ebc3-0d18-4f10-88b1-69f55a29566a _on_xmpp_proxy_close - terminate stream
[2012-07-05 12:17:54.359] [TRACE] [session.js] - 91ca672c-53d2-4d6e-964d-42b54f617478 56f0ebc3-0d18-4f10-88b1-69f55a29566a enqueue_bosh_response
[2012-07-05 12:17:54.359] [TRACE] [session.js] - 91ca672c-53d2-4d6e-964d-42b54f617478 get_response_object - holding 0 ro
[2012-07-05 12:17:54.359] [INFO] [session.js] - 91ca672c-53d2-4d6e-964d-42b54f617478 send_terminate_response - ro: false, condition: no-condition
[2012-07-05 12:17:54.361] [TRACE] [session.js] - 91ca672c-53d2-4d6e-964d-42b54f617478 _send_no_requeue::ro: false
[2012-07-05 12:17:54.361] [TRACE] [session.js] - 91ca672c-53d2-4d6e-964d-42b54f617478 get_response_object - holding 0 ro
[2012-07-05 12:17:54.361] [TRACE] [session.js] - 91ca672c-53d2-4d6e-964d-42b54f617478 send_pending_responses - pending.length: 0, Holding 0 response objects
@dhruvbird
Owner

You have a problem on this line:

[2012-07-05 12:17:34.863] [DEBUG] [http-server.js] - RECD: <body rid="14000053460001" xmlns="http://jabber.org/protocol/httpbind" sid=""><a... [129 more characters]

The client seems to be sending an empty sid with an non-empty rid. IIRC, your session is still alive on the server, but the client seems to have lost a handle to it.

@barnettech

The code works fine with the metajack punjab server (a test server provided for use with Strophe). Is it possible node-xmpp-bosh can't handle the strophe attach to re-connect to the rid/sid session?

@dhruvbird
Owner

To be able to re-attach to a certain sid/rid pair, they should both be present. There might be something fishy going on since node-xmpp-bosh is tested against strophe.js running on node.js.

The client is sending an empty sid. It would be helpful to:
1. Open an issue on the strophe web page to see if there's something wrong there
2. Capture and paste the trace logs for punjab and see if the same set of requests are coming in there

@barnettech

yes thank you you are right the real problem is via php I'm not able to get a SID. I get

[2012-07-05 16:08:22.522] [TRACE] [session.js] - f441b6de-92ff-451a-8d04-384f701a15d8 f8624e87-1a86-4b8c-b736-c38941906411 enqueue_stanza
[2012-07-05 16:08:22.522] [TRACE] [session.js] - f441b6de-92ff-451a-8d04-384f701a15d8 send_pending_responses - pending.length: 0, Holding 1 response objects
[2012-07-05 16:08:22.522] [TRACE] [session.js] - f441b6de-92ff-451a-8d04-384f701a15d8 _stitch_new_response - #streams: 1, next_stream: 0
[2012-07-05 16:08:22.522] [TRACE] [session.js] - f441b6de-92ff-451a-8d04-384f701a15d8 f8624e87-1a86-4b8c-b736-c38941906411 _stitch_response_for_stream - stitched
[2012-07-05 16:08:22.522] [TRACE] [session.js] - f441b6de-92ff-451a-8d04-384f701a15d8 get_response_object - return ro with rid: 15535594620000
[2012-07-05 16:08:22.523] [TRACE] [session.js] - f441b6de-92ff-451a-8d04-384f701a15d8 get_response_object - holding 0 ro
[2012-07-05 16:08:22.523] [TRACE] [session.js] - f441b6de-92ff-451a-8d04-384f701a15d8 send_pending_responses - ro: true, pending_stitched_responses: 1 - sending
[2012-07-05 16:08:22.523] [TRACE] [session.js] - f441b6de-92ff-451a-8d04-384f701a15d8 _send_no_requeue::ro: true
[2012-07-05 16:08:22.523] [TRACE] [session.js] - f441b6de-92ff-451a-8d04-384f701a15d8 _send_no_requeue::ro.rid: 15535594620000, this.rid: 15535594620000
[2012-07-05 16:08:22.524] [DEBUG] [response.js] - f441b6de-92ff-451a-8d04-384f701a15d8 SENT(15535594620000): <body xmlns="http://jabber.org/protocol/httpbind" stream="f8624e87-1a86-4b8c-b73... [534 more characters]
[2012-07-05 16:08:22.537] [TRACE] [http-server.js] - Processing POST request at location: /http-bind
[2012-07-05 16:08:22.537] [DEBUG] [http-server.js] - RECD: <body rid="15535594620001" xmlns="http://jabber.org/protocol/httpbind" sid=""><a... [129 more characters]
[2012-07-05 16:08:22.537] [TRACE] [bosh.js] - Processing Request
[2012-07-05 16:08:22.537] [TRACE] [bosh.js] - No_Session_ID Invalid Session
[2012-07-05 16:08:22.537] [TRACE] [session.js] - Sending invalid sid
[2012-07-05 16:08:22.539] [DEBUG] [response.js] - invalid-sid SENT(null): <body xmlns="http://jabber.org/protocol/httpbind" condition="item-not-found" mes... [44 more 

So my php code must not be processing

2012-07-05 16:08:22.537] [TRACE] [http-server.js] - Processing POST request at location: /http-bind
[2012-07-05 16:08:22.537] [DEBUG] [http-server.js] - RECD: <body rid="15535594620001" xmlns="http://jabber.org/protocol/httpbind" sid=""><a... [129 more characters]

the line with 129 more characters.

My php function to send and receive a response probably isn't getting a response or can't parse it:

function jabber_send_xml ($xmlposts) {
  global $_jabber_rid_;
  global $_jabber_sid_;
  //$bosh_url = 'http://bosh.metajack.im:5280/xmpp-httpbind';
  //$bosh_url = 'http://bosh.babson.edu:5280/http-bind';
  $bosh_url = 'http://drupaltest3.babson.edu/http-bind';
  $xml_repsonse = array();
  $count = 0;
  foreach ($xmlposts as $xmlpost) {
    $count = $count + 1;
    $_jabber_rid_ = $_jabber_rid_ + 1;
    $ch = curl_init($bosh_url);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_POST, TRUE);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlpost);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
    $header = array('Accept-Encoding: gzip, deflate','Content-Type: text/xml; charset=utf-8');
    curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
    curl_setopt($ch, CURLOPT_VERBOSE, 0);
    // Stops the dump to the screen and lets you capture it in a variable.
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlpost);
    $response = curl_exec($ch);
    watchdog('jabber', 'here is the response: <pre>' .
      print_r($response, TRUE) . '</pre>');
    dsm($response);
    $xml_response[] = simplexml_load_string($response);
    // Below lines are for debug.
    //watchdog('jabber', 'here is the xml posted: ' . $xmlpost);
    //watchdog('jabber', 'here is the response: <pre>' .
    // print_r($xml_response, TRUE) . '</pre>');
  }
  curl_close($ch);
  return $xml_response;
}

it does work with the metajack server. I'm trying to debug it.

@barnettech

We just got the code working with punjab. My guess is the response has to be parsed differently from node-xmpp-bosh than punjab? Maybe the xml differs a bit?

@dhruvbird
Owner

The xml wouldn't differ because it should be xep compliant. Try sending messages - maybe punjab is starting a new session every time??

@barnettech

Ok so I can send messages with php using node-xmpp-bosh, but when I go to get a rid and sid to return to stophe to use in it's attach() method node-xmpp-bosh takes a long long time to let my php script finish and return the rid and sid and its too late and strophe fails. In firebug the ajax shows the script keeps running a long time with a spinning wheel. Using punjab the same code quickly returns the sid and rid and strophe attach() gets what it needs in time and is happy. Is there a way to tell node-xmpp-bosh that I'm done and to disconnect and let my php script return to what it needs to do?

I tried to paste in my php but it didn't paste well.

These are the stanzas I'm sending:

$xmlposts[] = "<body rid='$_jabber_rid_' xmlns='http://jabber.org/protocol/httpbind' to='babson.edu' xml:lang='en' wait='60' hold='1' window='5' content='text/xml; charset=utf-8' ver='1.6' xmpp:version='1.0' xmlns:xmpp='urn:xmpp:xbosh'/>";
  $xml_response = jabber_send_xml($xmlposts);
  // Below lines are for debug.
  //watchdog('jabber', 'the sid in this object: </pre>' .
  // print_r((string) $xml_response[0]['sid'], TRUE) . '</pre>');
  $_jabber_sid_ = (string) $xml_response[0]['sid'];
  $xmlposts = array();
  // Now we get the PLAIN auth mechanism which is basically base64
  // encoded \u0000username\u0000password string which I have blacked out here.
  $jid = 'username@babson.edu';
  $username = 'username';
  $domain = 'babson.edu';
  //$password = $account->profile_google_password;
  //$decrypted = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5(JABBER_KEY), base64_decode($password), MCRYPT_MODE_CBC, md5(md5(JABBER_KEY))), "\0");
  $password = 'password';
  // In strophe its jbarnett@babson.edu\u0000jbarnett\u0000password
  $thepw = base64_encode($jid . chr(0) . $username . chr(0) . $password);
  $xmlposts[] = '<body rid="' . $_jabber_rid_ . '" xmlns="http://jabber.org/protocol/httpbind" sid="' . $_jabber_sid_ . '"><auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="PLAIN">' . $thepw . '</auth></body>';
  $xmlposts[] = "<body rid='" . jabber_get_next_rid() . "' xmlns='http://jabber.org/protocol/httpbind' sid='$_jabber_sid_' to='babson.edu' xml:lang='en' xmpp:restart='true' xmlns:xmpp='urn:xmpp:xbosh'/>";
  $xmlposts[] = "<body rid='" . jabber_get_next_rid() . "' xmlns='http://jabber.org/protocol/httpbind' sid='$_jabber_sid_'><iq type='set' id='_bind_auth_2' xmlns='jabber:client'><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'/></iq></body>";
  $xmlposts[] = "<body rid='" . jabber_get_next_rid() . "' xmlns='http://jabber.org/protocol/httpbind' sid='$_jabber_sid_'><iq type='set' id='_session_auth_2' xmlns='jabber:client'><session xmlns='urn:ietf:params:xml:ns:xmpp-session'/></iq></body>";
  // Below line is an example if you want to test sending an actual chat
  // message.
  $xmlposts[] = "<body rid='" . jabber_get_next_rid() . "' xmlns='http://jabber.org/protocol/httpbind' sid='$_jabber_sid_'><message to='barnettech@gmail.com' type='chat' xmlns='jabber:client'><body>test helloworld from my php xmpp api!</body><active xmlns='http://jabber.org/protocol/chatstates'/></message></body>";
  $xml_response = jabber_send_xml($xmlposts);

Here is the original PHP code: http://pastebin.com/aeirdxdD

@dhruvbird
Owner

@barnettech You should ideally wait for the response from the bosh/xmpp server and send the next packet based on what the response is. You can't just send out a bunch of packets without checking what the response is (see jabber_send_xml). The BOSH XEP mentions that a client needs to wait for a stream:features/ packet before it can start the auth. process.

Try running node-xmpp-bosh with pidgin_compatible set to true in the config. file and see if it works.

@barnettech

actually the sending out a bunch of packets thing is working in this case, and "test helloworld from my php xmpp api!" test message gets sent out no problem which means all the packets get processed -- and it does work every time. The problem is when it's done the php is still listening for responses or something and can't continue on processing. Is there a way to force php to disconnect from bosh?

@dhruvbird
Owner

So, in bosh, there is a concept of "hold"ing connections so that the server can immediately push updates it receives from the xmpp server to the client. What is happening is that the bosh server is "hold"ing your connection in the hope that the the server will have something to send you. It is expected behaviour. For whatever reason (unknown to me), the server has something to send to you in the punjab case.

I think your best bet in this case is to send a message to yourself so that the response is always available after 1 round trip time.

BOSH was meant to be used in a non-blocking environment.

@dhruvbird
Owner

@barnettech Has your issue been resolved?

@dhruvbird
Owner

Too old??

@dhruvbird dhruvbird closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.