--- lib/jabber/XMPP/XMLStream.php	2014-09-24 13:45:53.000000000 +0200
+++ lib/jabber/XMPP/XMLStream.php	2015-02-23 18:08:53.947131991 +0100
@@ -400,7 +400,9 @@
 				if ($this->reconnect) {
 					$this->doReconnect();
 				} else {
-					fclose($this->socket);
+	          		if( $this->socket != NULL ) {
+						fclose($this->socket);
+	          		}
 					$this->socket = NULL;
 					return false;
 				}
@@ -411,7 +413,9 @@
 					if($this->reconnect) {
 						$this->doReconnect();
 					} else {
-						fclose($this->socket);
+	            		if($this->socket !== NULL) {
+							fclose($this->socket);
+	            		}
 						$this->socket = NULL;
 						return false;
 					}
