Lance Stout
c43c7be86c
Make last_xml usage a little more explict.
2012-02-17 11:40:07 -08:00
Lance Stout
c58462f154
Fix undeclared variable usage for reconnect.
2012-02-17 11:12:48 -08:00
Lance Stout
fb2582e53b
Fix fixing remove_stanza()
...
Fixes issue #146
2012-02-16 07:25:44 -08:00
Lance Stout
d807613117
Don't retrieve cert until a connection is made.
2012-02-16 07:02:56 -08:00
Lance Stout
6d922d00c3
Fix remove_stanza().
...
Fixes issue #146
2012-02-16 07:02:19 -08:00
Lance Stout
61ea84093b
Don't shutdown completely after handling SyntaxError.
...
The ``shutdown = True`` line was preventing the stream from reconnecting
after handling the error.
Fixes issues #101 , #145
2012-02-10 19:28:12 -08:00
Lance Stout
e76d6a481f
Fix undefined variable references when DNS timeouts.
2012-02-10 19:20:17 -08:00
Lance Stout
ca5145c210
Fix IPv6 query logging.
2012-02-10 06:46:51 +01:00
Lance Stout
1a272fd276
Add support for querying and connecting to IPv6 addresses.
...
Tested using servers provided by Florian Jensen (flosoft.biz)
during the 2012 FOSDEM XMPP Summit.
Fixes issue #94 .
2012-02-09 21:28:28 -08:00
Lance Stout
952260b423
Add ssl_cert event (direct).
...
The payload is a dictionary of parsed cert data, as provided by
Python's getpeercert() socket method. It unfortunately does not
provide much detail beyond basic info.
2012-02-04 14:16:37 +01:00
Lance Stout
f98e5a03de
Fix typo s/is_set/is_set()
2012-02-02 18:14:48 +01:00
Lance Stout
3ab7c8bcc3
Make socket_error run as a direct event to ensure that it is handled.
...
Socket errors that occur before stream processing begins could not be
handled as the event loop would not be running yet.
Resolves issue #142
2012-01-28 18:54:46 -08:00
Lance Stout
1e01903072
Revert "Remove stream feature handlers on session_start."
...
This reverts commit 4274f49ada
.
The SASL mech was choking on this, so let's send it back for some
more refining.
2012-01-18 11:51:00 -08:00
Lance Stout
86d8736dcc
Hash JIDs based on full JID string.
...
This makes JID objects equivalent to strings in dictionaries, etc.
>>> j = JID('foo@example.com')
>>> s = 'foo@example.com'
>>> d = {j: 'yay'}
>>> d[j]
'yay'
>>> d[s]
'yay'
>>> d[s] = 'yay!!'
>>> d[j]
'yay!!'
2012-01-17 23:03:48 -08:00
Lance Stout
2923f56561
Pre-parse StanzaPath paths to speed up matching.
...
The parsing and namespace cleaning isn't terribly expensive, but it does
add up. It was adding an extra 5sec when processing 100,000 basic
message stanzas.
2012-01-17 22:28:44 -08:00
Lance Stout
4274f49ada
Remove stream feature handlers on session_start.
...
Based on profiling, using around 35 stream handlers quarters the number
of basic message stanzas that can be processed in a second, in
comparison to only using the bare minimum of four handlers.
To help, we can drop handlers for stream features once the session
has started. So that we can re-enable these handlers when a stream
must restart, the 'stream_start' event has been added which fires
whenever a stream header is received.
The 'stream_start' event is a more generic replacement for the
existing start_stream_handler() method.
2012-01-17 22:14:24 -08:00
Lance Stout
de35848500
Don't serialize XML unless we need to.
2012-01-14 10:54:48 -08:00
Lance Stout
e0545bf0bc
Merge branch 'develop' into develop-1.1
2011-12-31 01:29:12 -05:00
Lance Stout
03bc38f7e3
Add docs on using Iq stanzas.
2011-12-31 01:28:41 -05:00
Lance Stout
1a61bdb302
Ensure that stanza plugins work as expected if the XML is appended.
2011-12-28 09:53:22 -05:00
Lance Stout
2f2ebb37e4
Merge branch 'develop' into develop-1.1
2011-12-27 18:05:42 -05:00
Lance Stout
42a86fe0d4
Disconnect when a SyntaxError is found.
...
This should resolve issue #102
2011-12-27 18:01:26 -05:00
Lance Stout
f6e30edbc4
Log received data AFTER filtering.
...
This allows applications to filter out sensitive information, such
as passwords, so that it won't appear in the logs.
It does mean that the debug logs will not show the actual received
data, and there will be no indication of tampering, unless the
filter author explicitly logs and notes that a change was made.
2011-12-14 21:14:27 -08:00
Lance Stout
cb635dcd5a
Add parameter docs for add_filter.
2011-12-12 22:37:19 -08:00
Lance Stout
eff3330e75
Add support for incoming/outgoing filters.
...
A filter accepts and returns a stanza, but potentially modified.
To prevent sending/receiving a stanza, a filter may return None.
Incoming:
self.add_filter('in', in_filter)
Outgoing:
self.add_filter('out', out_filter)
Filters are applied in the order thay are added. However, you may
add an order parameter, which is the place in the list to insert the
filter:
self.add_filter('in', in_filter, order=0)
2011-12-12 22:17:07 -08:00
Lance Stout
62e6d6fb4c
Fix iterable substanzas when added as normal plugin.
...
If an iterable plugin was an enabled, it wasn't added to
the iterables list.
2011-12-11 17:04:58 -08:00
Lance Stout
efe1b9f5a9
Allow sending stanzas on session_end.
...
May set self.disconnect_wait=True so that all disconnect
calls wait for the send queue to empty, unless explicitly
overridden with wait=False.
The session_end now fires before closing the socket so
that final stanzas may be sent, such as unavailable presences
for components.
2011-12-09 23:56:39 -08:00
Lance Stout
2a67a31120
Prevent hang when terminating during delayed connection.
2011-12-07 22:16:58 -08:00
Lance Stout
8922e2050a
Update the API docs for XMLStream
2011-12-04 20:35:17 -08:00
Lance Stout
a85891c611
Add API docs for the scheduler
2011-12-04 16:43:05 -08:00
Lance Stout
2586fdffda
Update api docs for handlers and matchers
2011-12-04 16:26:14 -08:00
Lance Stout
b9332142c9
Update api docs for JID
2011-12-04 13:42:46 -08:00
Florent Le Coz
4eb7eeb40f
Send the encoded data (bytes) and not the str, on the socket.
2011-11-25 01:45:43 +08:00
Lance Stout
a1d64fa215
Experimental support for handling SSL write errors.
2011-11-23 23:59:05 -08:00
Lance Stout
5f44c0e678
Add docs for filesocket
2011-11-22 16:33:38 -08:00
Lance Stout
b87c4d786d
Update tostring docs, plus more doc cleanup
2011-11-22 16:25:33 -08:00
Lance Stout
6906c15e8e
Update docs for tostring
2011-11-22 15:25:02 -08:00
Lance Stout
4498e992a2
Add more stanzabase docs
2011-11-21 23:17:39 -08:00
Lance Stout
2b0a05ee32
Update stanzabase docs
2011-11-21 21:51:19 -08:00
Lance Stout
862a2a1440
Ensure that reconnection happens properly after connection loss.
...
Calling reconnect() simultaneously from multiple threads (like when
using XEP-0199 keepalive) could break because the connection state
can transition and break the state expectations in one of the
reconnect() calls.
2011-11-20 12:18:37 -08:00
Lance Stout
fba60ffff1
Convert daemon threads back into normal threads.
...
This may need to be reverted if CTRL-C handling breaks, but everything
works fine so far in testing.
Resolves issue #95 .
2011-11-20 12:17:35 -08:00
Lance Stout
d1a945a305
Tidy up logging some more
2011-11-19 19:18:43 -08:00
Lance Stout
685b9ab102
Fix logging exceptions from formatting issues.
2011-11-19 19:08:27 -08:00
Lance Stout
24f27c0fe3
Pass generic connection errors to XMLStream.exception()
2011-11-19 19:01:07 -08:00
Lance Stout
3019c82d8a
Use a list comprehension instead of filter() to work with Python3.
2011-11-19 18:49:18 -08:00
Lance Stout
b54cc97e4c
Merge remote-tracking branch 'vijayp/master' into HEAD
...
Conflicts:
examples/ping.py
sleekxmpp/basexmpp.py
sleekxmpp/clientxmpp.py
sleekxmpp/features/feature_bind/bind.py
sleekxmpp/features/feature_mechanisms/mechanisms.py
sleekxmpp/plugins/gmail_notify.py
sleekxmpp/plugins/jobs.py
sleekxmpp/plugins/xep_0009/remote.py
sleekxmpp/plugins/xep_0009/rpc.py
sleekxmpp/plugins/xep_0012.py
sleekxmpp/plugins/xep_0045.py
sleekxmpp/plugins/xep_0050/adhoc.py
sleekxmpp/plugins/xep_0078/legacyauth.py
sleekxmpp/plugins/xep_0085/chat_states.py
sleekxmpp/plugins/xep_0199/ping.py
sleekxmpp/plugins/xep_0224/attention.py
sleekxmpp/xmlstream/handler/waiter.py
sleekxmpp/xmlstream/matcher/xmlmask.py
sleekxmpp/xmlstream/xmlstream.py
Conflicts:
examples/ping.py
sleekxmpp/basexmpp.py
sleekxmpp/clientxmpp.py
sleekxmpp/features/feature_bind/bind.py
sleekxmpp/features/feature_mechanisms/mechanisms.py
sleekxmpp/plugins/gmail_notify.py
sleekxmpp/plugins/jobs.py
sleekxmpp/plugins/xep_0009/remote.py
sleekxmpp/plugins/xep_0009/rpc.py
sleekxmpp/plugins/xep_0012.py
sleekxmpp/plugins/xep_0045.py
sleekxmpp/plugins/xep_0050/adhoc.py
sleekxmpp/plugins/xep_0078/legacyauth.py
sleekxmpp/plugins/xep_0085/chat_states.py
sleekxmpp/plugins/xep_0199/ping.py
sleekxmpp/plugins/xep_0224/attention.py
sleekxmpp/xmlstream/handler/waiter.py
sleekxmpp/xmlstream/matcher/xmlmask.py
sleekxmpp/xmlstream/xmlstream.py
2011-11-19 18:23:26 -08:00
Vijay Pandurangan
e3b9d5abbf
double copy
2011-11-19 16:03:17 -08:00
Vijay Pandurangan
2332970cf2
elide unnecessary copy
2011-11-19 16:02:41 -08:00
Vijay Pandurangan
48af3d3322
remove unnecessary copies when only one handler matches. This was taking up ~ 15% of CPU on moderate load.
2011-11-19 15:59:38 -08:00
Lance Stout
429c94d6a9
Tidy up logging calls.
2011-11-19 12:07:57 -08:00
Vijay Pandurangan
deb52ad350
This change stops sleekxmpp from spending huge amounts of time unnecessarily computing logging data that may never be used. This is a HUGE performance improvement; in some of my test runs, unnecessary string creation was accounting for > 60% of all CPU time.
...
Note that using % in a string will _always_ perform the sting substitutions, because the strings are constructed before the function is called. So log.debug('%s' % expensiveoperation()) will take about the same CPU time whether or not the logging level is DEBUG or INFO. if you use , no substitutions are performed unless the string is actually logged
2011-11-20 03:39:05 +08:00
Vijay Pandurangan
6f3cc77bb5
This change stops sleekxmpp from spending huge amounts of time unnecessarily computing logging data that may never be used. This is a HUGE performance improvement; in some of my test runs, unnecessary string creation was accounting for > 60% of all CPU time.
...
Note that using % in a string will _always_ perform the sting substitutions, because the strings are constructed before the function is called. So log.debug('%s' % expensiveoperation()) will take about the same CPU time whether or not the logging level is DEBUG or INFO. if you use , no substitutions are performed unless the string is actually logged
2011-11-19 11:30:44 -08:00
Lance Stout
0c86f8288d
No need to continue processing loop if an error ocurred and auto_reconnect=False.
2011-11-14 11:21:05 -08:00
Lance Stout
43c4d23896
Explicitly test for inequality in JIDs.
...
Fixes issue #113
2011-11-14 09:15:43 -08:00
Lance Stout
b8efcc7cf0
Don't just call self.disconnect in self.reconnect.
...
It messes up the auto_reconnect value and causes the XML processing
loop to spin wildly with errors on a stream disconnect.
2011-11-08 19:23:53 -08:00
Lance Stout
888e286a09
Continue trying to reconnect, even if the attempt fails.
...
The transition from disconnected to connected states must be done in a
loop in case the transition fails, not just once and hope it worked.
2011-11-07 01:13:34 -08:00
Lance Stout
335dc2927b
Break reference cycle to fix potential memory leaks for callback handlers.
2011-10-08 17:31:30 -04:00
Lance Stout
262da78ca7
Fix del_event_handler for Python3 (different semantics for filter()).
...
Fixes issue #103
2011-09-23 12:03:49 -04:00
Lance Stout
0b83edf439
Fix regression for handling the case where the server terminates the stream.
...
The processing loop was continuing to call __read_xml after </stream>
was received, which caused SyntaxErrors (can't find starting element).
This should fix issue #102
2011-09-22 01:32:44 -04:00
Nathan Fritz
cf7fcf496e
SyntaxError requires a restart
2011-09-19 11:53:09 -07:00
Lance Stout
6f72c05ebf
Add whitespace keepalive option.
...
May be disabled by setting:
self.whitespace_keepalive = False
The keepalive interval can be adjusted using:
self.whitespace_keepalive_interval = 300
The default interval is 5min.
2011-09-01 16:24:09 -07:00
Lance Stout
0af35c2224
Fix memory reference bugs.
2011-09-01 00:50:45 -07:00
Lance Stout
e3e985220e
Simplify the main process loop.
2011-08-25 17:08:20 -07:00
Lance Stout
802dd8393d
Make the timeout for event queue checks configurable.
...
Now defaults xmlstream.WAIT_TIMEOUT, and settable with
self.wait_timeout.
The new default timeout is 1sec instead of 5sec.
2011-08-25 16:45:34 -07:00
Lance Stout
fe6bc31c60
Added XMLStream.configure_dns.
...
This can be overridden to do custom configuration for the DNS resolver,
or any other DNS related tasks such as calling the system's res_init().
2011-08-25 16:18:26 -07:00
Lance Stout
2162d6042e
Session timeout now defaults to 45sec, but can be adjusted.
...
e.g.
self.session_timeout = 15
It is also managed by XMLStream instead of ClientXMPP now.
2011-08-25 15:40:13 -07:00
Lance Stout
b8a4ffece9
Handle sending stanzas in chunks if the socket has poor performance.
2011-08-25 15:08:45 -07:00
Lance Stout
d929e0deb2
Shutdown socket before closing.
2011-08-25 13:48:43 -07:00
Lance Stout
4c08c9c524
Update scheduler with locks and ability to remove tasks.
...
Scheduled tasks must have a unique name.
2011-08-25 13:34:30 -07:00
Lance Stout
63b8444abe
Add overridable method self.configure_socket().
...
Allows for setting app specific socket timeouts and other socket options.
2011-08-25 00:22:26 -07:00
Lance Stout
84f9505a8d
Fix handling of DNS exceptions.
2011-08-24 22:40:57 -07:00
Lance Stout
e02a42a008
Route all unhandled exceptions through XMLStream.exception.
...
Or through an equivalent override.
2011-08-18 16:12:51 -07:00
Lance Stout
3e51126e18
PEP8 edits
2011-08-18 02:46:48 -07:00
Lance Stout
e86e6eae81
Up the timeout to 30sec instead of 10sec.
2011-08-18 01:10:25 -07:00
Nathan Fritz
f75b6bf955
added inline documentation for new dns methods
2011-08-18 01:04:01 -07:00
Lance Stout
cd7cd30b4c
Fix exceptions for Python3
2011-08-18 00:47:07 -07:00
Nathan Fritz
3853898ab3
DNS is now properly checked and different answers are tried for each reconnect until exhausted
2011-08-18 00:35:18 -07:00
Lance Stout
9fdd85d9f1
I've seen people complain about Sleek taking so long to disconnect.
...
Added logging to say that we're waiting for the server to end the stream
from its end.
2011-08-13 08:58:07 -07:00
Lance Stout
bd427849fb
Reduce the maximum delay between connection retries to 10min.
2011-08-12 17:17:05 -07:00
Lance Stout
47bc50d9fb
Cosmetic PEP8 fixes.
2011-08-04 22:37:22 -07:00
Lance Stout
93a4a3f8a0
Fix Python3 issue with dict.has_key()
2011-08-04 22:36:23 -07:00
Nathan Fritz
7f90de887a
added block as process option and updated documentation. added typical use example to ClientXMPP.
2011-08-04 21:49:32 -07:00
Lance Stout
b9764cc120
Clean up and unify tostring once and for all.
...
Packaging for Python3 just got easier.
2011-08-04 11:41:36 -07:00
Lance Stout
d94517d9ca
Merge branch 'develop' into stream_features
2011-08-03 17:37:15 -07:00
Lance Stout
3918ddb075
Merge branch 'develop' into stream_features
2011-08-03 17:02:33 -07:00
Lance Stout
e022b2a36c
Add support for HTTP Proxy connections.
2011-07-27 19:35:03 -07:00
Lance Stout
5efb170e1d
Added wait parameter to disconnect.
...
If wait=True, then the disconnect call will block until
the send queue has emptied.
WARNING: Using wait=True when more stanzas are being added to the
queue than can be processed such that the queue is never empty
will cause the disconnect call to block indefinitely without actually
disconnecting.
2011-07-04 18:47:57 -07:00
Lance Stout
04def6d925
Merge branch 'develop' into stream_features
2011-07-01 15:19:37 -07:00
Lance Stout
2a2ac73845
So using sys.excepthook to catch errors only works once.
...
The error bubbles through the event processing loop, breaking it and
hanging the application.
Instead, there is now a .exception(e) method on XMLStream which may
be overridden or reassigned that will receive all unhandled exceptions
(read: not XMPPError) from event and stream handlers.
2011-07-01 15:18:10 -07:00
Lance Stout
fa716457a5
Merge branch 'develop' into stream_features
2011-06-20 16:27:55 -07:00
Lance Stout
d8d9e8df16
Fix stanza clobbering when replying to errors.
...
If a stanza handler raised an exception, the exception was processed
and replied by the modified stanza, not a stanza with the original
content.
A copy is now made before handler processing, and if an exception occurs
it is the copy that processes the exception using the original content.
2011-06-20 16:25:56 -07:00
Lance Stout
7a60e4b458
Merge branch 'develop' into stream_features
2011-06-10 15:14:51 -07:00
Lance Stout
e219c0f976
Added session_end event and some docs.
...
For now, session_end is the same as disconnected, but once support is
added later for stream management, the two events will become distinct.
Plugins should add handlers for session_end for cleaning any session
state.
2011-06-08 10:24:25 -07:00
Lance Stout
8f9100c762
Merge branch 'develop' into stream_features
2011-06-01 15:17:13 -07:00
Lance Stout
1469323350
Cache stanza if sending fails.
...
The stanza will be sent first once the send queue is reactivated
after session start.
Stanzas sent by skipping the queue will not be cached.
2011-06-01 15:10:44 -07:00
Lance Stout
83a73ac9b7
Merge branch 'develop' into stream_features
...
Conflicts:
sleekxmpp/clientxmpp.py
2011-05-31 11:05:54 -07:00
Lance Stout
a81162edd2
Apply connection backoff to reconnect attempts.
...
Backoff was only being done for the initial connection attempt
before. Now any reconnection will start with a minimum 1 sec
delay which will approximately double between attempts.
2011-05-31 10:55:15 -07:00
Lance Stout
8080b4cae2
Cleanup logging and exception handling.
...
The syntax and attribute errors raised during a disconnect/reconnect
attempt are now caught and produce nicer log messages.
2011-05-31 10:23:05 -07:00
Lance Stout
1735c194cd
Don't use the send queue for stream initialization.
...
Use the parameter now=True to skip the queue when
sending Iq stanzas, or using xmpp.send().
2011-05-27 17:00:57 -07:00
Lance Stout
6997b2fbf8
Fix typo for SSL certificate use.
2011-05-27 16:39:45 -07:00