When reporting issues include
version 4.3.3
java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:210)
at java.net.SocketInputStream.read(SocketInputStream.java:141)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:246)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:286)
at java.io.BufferedInputStream.read(BufferedInputStream.java:345)
at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:735)
at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:678)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1587)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1492)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:480)
at main.java.com.tecfrac.external.HttpFileUploadManager.upload(HttpFileUploadManager.java:524)
at main.java.com.tecfrac.external.HttpFileUploadManager.uploadFile(HttpFileUploadManager.java:276)
at main.java.com.tecfrac.smack.Client.uploadFile(Client.java:239)
at main.java.com.tecfrac.smack.Client.main(Client.java:269)
10:02:49 SENT (0):
<stream:stream xmlns='jabber:client' to='192.168.3.164' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' from='admin@192.168.3.164' xml:lang='en-US'>
10:02:49 RECV (0): ?xml version='1.0' encoding='UTF-8'?>
<stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" from=
10:02:49 RECV (0): "localhost" id="3urwqz303e" xml:lang="en-US" version="1.0">
Oct 06, 2021 10:02:49 AM org.jivesoftware.smack.AbstractXMPPConnection onStreamOpen
WARNING: Domain reported by server 'localhost' does not match configured domain '192.168.3.164'
10:02:49 RECV (0):
<stream:features>
<starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls">
</starttls>
<mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl">
<mechanism>
PLAIN
</mechanism>
</mechanisms>
<compression xmlns="http://jabber.org/features/compress">
<method>
zlib
</method>
</compression>
<ver xmlns="urn:xmpp:features:rosterver"/>
<register xmlns="http://jabber.org/features/iq-register"/>
<c xmlns="http://jabber.org/protocol/caps" hash="sha-1" node="https://www.igniterealtime.org/projects/openfire/" ver="uelH8ezolv4vAd+ckyZKHEpnc1I="/>
</stream:features>
10:02:49 SENT (0):
<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='PLAIN'>
AGFkbWluAFRFU1Q=
</auth>
10:02:49 RECV (0):
<success xmlns="urn:ietf:params:xml:ns:xmpp-sasl"/>
10:02:49 SENT (0):
<stream:stream xmlns='jabber:client' to='192.168.3.164' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' from='admin@192.168.3.164' id='3urwqz303e' xml:lang='en-US'>
10:02:49 RECV (0): ?xml version='1.0' encoding='UTF-8'?>
<stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" from=
10:02:49 RECV (0): "localhost" id="3urwqz303e" xml:lang="en-US" version="1.0">
<stream:features>
<compression xmlns="http://jabber.org/features/compress">
<method>
zlib
</method>
</compression>
<ver xmlns="urn:xmpp:features:rosterver"/>
<bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"/>
<session xmlns="urn:ietf:params:xml:ns:xmpp-session">
<optional/>
</session>
<sm xmlns='urn:xmpp:sm:2'/>
<sm xmlns='urn:xmpp:sm:3'/>
<c xmlns="http://jabber.org/protocol/caps" hash="sha-1" node="https://www.igniterealtime.org/projects/openfire/" ver="uelH8ezolv4vAd+ckyZKHEpnc1I="/>
</stream:features>
Oct 06, 2021 10:02:49 AM org.jivesoftware.smack.AbstractXMPPConnection onStreamOpen
WARNING: Domain reported by server 'localhost' does not match configured domain '192.168.3.164'
10:02:49 SENT (0):
<iq id='TQFFS-1' type='set'>
<bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'>
<resource>
tornado
</resource>
</bind>
</iq>
10:02:49 RECV (0):
<iq type="result" id="TQFFS-1" to="localhost/3urwqz303e">
<bind xmlns="urn:ietf:params:xml:ns:xmpp-bind">
<jid>
admin@localhost/tornado
</jid>
</bind>
</iq>
10:02:49 SENT (0):
<enable xmlns='urn:xmpp:sm:3' resume='true'/>
10:02:49 RECV (0):
<enabled xmlns="urn:xmpp:sm:3" resume="true" id="dG9ybmFkbwAzdXJ3cXozMDNl" location="localhost" max="600"/>
10:02:49 User logged (0): admin@localhost:5222/tornado
10:02:49 SENT (0):
<iq id='TQFFS-3' type='get'>
<query xmlns='jabber:iq:roster'>
</query>
</iq>
10:02:49 XMPPConnection authenticated (XMPPTCPConnection[admin@localhost/tornado] (0))
10:02:49 RECV (0):
<iq type="result" id="TQFFS-3" to="admin@localhost/tornado">
<query xmlns="jabber:iq:roster" ver="-127600968">
<item jid="hussein@localhost" name="hussein" subscription="from">
<group>
Friends
</group>
</item>
<item jid="mohamad@localhost" name="mohamad" subscription="both">
<group>
Friends
</group>
</item>
</query>
</iq>
10:02:49 SENT (0):
<presence id='STE2E-1'>
<priority>
0
</priority>
<c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='https://igniterealtime.org/projects/smack' ver='NfJ3flI83zSdUDzCEICtbypursw='/>
</presence>
10:02:49 RECV (0):
<presence id="STE2E-1" from="admin@localhost/tornado" to="admin@localhost/tornado">
<priority>
0
</priority>
<c xmlns="http://jabber.org/protocol/caps" hash="sha-1" node="https://igniterealtime.org/projects/smack" ver="NfJ3flI83zSdUDzCEICtbypursw=">
</c>
</presence>
10:02:49 SENT (0):
<iq to='localhost' id='STE2E-2' type='get'>
<query xmlns='http://jabber.org/protocol/disco#info' node='https://www.igniterealtime.org/projects/openfire/#uelH8ezolv4vAd+ckyZKHEpnc1I='>
</query>
</iq>
10:02:49 RECV (0):
<iq type="result" id="STE2E-2" from="localhost" to="admin@localhost/tornado">
<query xmlns="http://jabber.org/protocol/disco#info" node="https://www.igniterealtime.org/projects/openfire/#uelH8ezolv4vAd+ckyZKHEpnc1I=">
<identity category="server" name="Openfire Server" type="im"/>
<identity category="pubsub" type="pep"/>
<feature var="http://jabber.org/protocol/pubsub#retrieve-default"/>
<feature var="http://jabber.org/protocol/pubsub#purge-nodes"/>
<feature var="http://jabber.org/protocol/pubsub#subscription-options"/>
<feature var="http://jabber.org/protocol/pubsub#outcast-affiliation"/>
<feature var="msgoffline"/>
<feature var="jabber:iq:register"/>
<feature var="http://jabber.org/protocol/pubsub#delete-nodes"/>
<feature var="http://jabber.org/protocol/pubsub#config-node"/>
<feature var="http://jabber.org/protocol/pubsub#retrieve-items"/>
<feature var="http://jabber.org/protocol/pubsub#auto-create"/>
<feature var="http://jabber.org/protocol/disco#items"/>
<feature var="http://jabber.org/protocol/pubsub#persistent-items"/>
<feature var="http://jabber.org/protocol/pubsub#create-and-configure"/>
<feature var="http://jabber.org/protocol/pubsub#retrieve-affiliations"/>
<feature var="urn:xmpp:time"/>
<feature var="http://jabber.org/protocol/pubsub#manage-subscriptions"/>
<feature var="urn:xmpp:bookmarks-conversion:0"/>
<feature var="http://jabber.org/protocol/offline"/>
<feature var="http://jabber.org/protocol/pubsub#auto-subscribe"/>
<feature var="http://jabber.org/protocol/pubsub#publish-options"/>
<feature var="urn:xmpp:carbons:2"/>
<feature var="http://jabber.org/protocol/address"/>
<feature var="http://jabber.org/protocol/pubsub#collections"/>
<feature var="http://jabber.org/protocol/pubsub#retrieve-subscriptions"/>
<feature var="vcard-temp"/>
<feature var="http://jabber.org/protocol/pubsub#subscribe"/>
<feature var="http://jabber.org/protocol/pubsub#create-nodes"/>
<feature var="http://jabber.org/protocol/pubsub#get-pending"/>
<feature var="urn:xmpp:blocking"/>
<feature var="http://jabber.org/protocol/pubsub#multi-subscribe"/>
<feature var="http://jabber.org/protocol/pubsub#presence-notifications"/>
<feature var="urn:xmpp:ping"/>
<feature var="http://jabber.org/protocol/pubsub#filtered-notifications"/>
<feature var="http://jabber.org/protocol/pubsub#item-ids"/>
<feature var="http://jabber.org/protocol/pubsub#meta-data"/>
<feature var="jabber:iq:roster"/>
<feature var="http://jabber.org/protocol/pubsub#instant-nodes"/>
<feature var="http://jabber.org/protocol/pubsub#modify-affiliations"/>
<feature var="http://jabber.org/protocol/pubsub"/>
<feature var="http://jabber.org/protocol/pubsub#publisher-affiliation"/>
<feature var="http://jabber.org/protocol/pubsub#access-open"/>
<feature var="jabber:iq:version"/>
<feature var="http://jabber.org/protocol/pubsub#retract-items"/>
<feature var="jabber:iq:privacy"/>
<feature var="jabber:iq:last"/>
<feature var="http://jabber.org/protocol/commands"/>
<feature var="http://jabber.org/protocol/pubsub#publish"/>
<feature var="http://jabber.org/protocol/disco#info"/>
<feature var="jabber:iq:private"/>
<feature var="http://jabber.org/protocol/rsm"/>
<x xmlns="jabber:x:data" type="result">
<field var="FORM_TYPE" type="hidden">
<value>
http://jabber.org/network/serverinfo
</value>
</field>
<field var="admin-addresses" type="list-multi">
<value>
xmpp:admin@localhost
</value>
<value>
mailto:admin@example.com
</value>
<value>
xmpp:mohamad@localhost
</value>
<value>
xmpp:root@localhost
</value>
</field>
</x>
<x xmlns="jabber:x:data" type="result">
<field var="FORM_TYPE" type="hidden">
<value>
urn:xmpp:dataforms:softwareinfo
</value>
</field>
<field var="os">
<value>
Linux
</value>
</field>
<field var="os_version">
<value>
3.10.0-1160.el7.x86_64 i386 - Java 1.8.0_202
</value>
</field>
<field var="software">
<value>
Openfire
</value>
</field>
<field var="software_version">
<value>
4.6.4
</value>
</field>
</x>
</query>
</iq>
Oct 06, 2021 10:02:49 AM org.jivesoftware.smackx.xdata.provider.DataFormProvider parseField
WARNING: The Field 'os' from FORM_TYPE 'urn:xmpp:dataforms:softwareinfo' is not registered. Field type is unknown, assuming text-single.
Oct 06, 2021 10:02:49 AM org.jivesoftware.smackx.xdata.provider.DataFormProvider parseField
WARNING: The Field 'os_version' from FORM_TYPE 'urn:xmpp:dataforms:softwareinfo' is not registered. Field type is unknown, assuming text-single.
Oct 06, 2021 10:02:49 AM org.jivesoftware.smackx.xdata.provider.DataFormProvider parseField
WARNING: The Field 'software' from FORM_TYPE 'urn:xmpp:dataforms:softwareinfo' is not registered. Field type is unknown, assuming text-single.
Oct 06, 2021 10:02:49 AM org.jivesoftware.smackx.xdata.provider.DataFormProvider parseField
WARNING: The Field 'software_version' from FORM_TYPE 'urn:xmpp:dataforms:softwareinfo' is not registered. Field type is unknown, assuming text-single.
10:02:49 SENT (0):
<iq to='localhost' id='TQFFS-5' type='get'>
<query xmlns='http://jabber.org/protocol/disco#items'>
</query>
</iq>
10:02:49 RECV (0):
<iq type="result" id="TQFFS-5" from="localhost" to="admin@localhost/tornado">
<query xmlns="http://jabber.org/protocol/disco#items">
<item jid="proxy.localhost" name="Socks 5 Bytestreams Proxy"/>
<item jid="httpfileupload.localhost" name="localhost"/>
<item jid="pubsub.localhost" name="Publish-Subscribe service"/>
<item jid="conference.localhost" name="Public Chatrooms"/>
</query>
</iq>
10:02:49 SENT (0):
<iq to='proxy.localhost' id='STE2E-3' type='get'>
<query xmlns='http://jabber.org/protocol/disco#info'>
</query>
</iq>
10:02:49 SENT (0):
<r xmlns='urn:xmpp:sm:3'/>
10:02:49 RECV (0):
<iq type="result" id="STE2E-3" from="proxy.localhost" to="admin@localhost/tornado">
<query xmlns="http://jabber.org/protocol/disco#info">
<identity category="proxy" name="SOCKS5 Bytestreams Service" type="bytestreams"/>
<feature var="http://jabber.org/protocol/bytestreams"/>
<feature var="http://jabber.org/protocol/disco#info"/>
</query>
</iq>
10:02:49 RECV (0):
<r xmlns='urn:xmpp:sm:3' />
10:02:49 SENT (0):
<iq to='httpfileupload.localhost' id='STE2E-4' type='get'>
<query xmlns='http://jabber.org/protocol/disco#info'>
</query>
</iq>
10:02:49 RECV (0):
<a xmlns='urn:xmpp:sm:3' h='5' />
10:02:49 SENT (0):
<a xmlns='urn:xmpp:sm:3' h='5'/>
10:02:49 RECV (0):
<iq type="result" id="STE2E-4" from="httpfileupload.localhost" to="admin@localhost/tornado">
<query xmlns="http://jabber.org/protocol/disco#info">
<identity category="store" type="file" name="localhost"/>
<feature var="http://jabber.org/protocol/disco#info"/>
<feature var="urn:xmpp:ping"/>
<feature var="jabber:iq:last"/>
<feature var="urn:xmpp:time"/>
<feature var="urn:xmpp:http:upload:0"/>
<feature var="urn:xmpp:http:upload"/>
</query>
</iq>
10:02:49 SENT (0):
<iq to='httpfileupload.localhost' id='TQFFS-7' type='get'>
<request xmlns='urn:xmpp:http:upload:0' filename='logo_large.png' size='1678' content-type='application/octet-stream'/>
</iq>
10:02:49 RECV (0):
<iq type="result" id="TQFFS-7" from="httpfileupload.localhost" to="admin@localhost/tornado">
<slot xmlns="urn:xmpp:http:upload:0">
<put url="http://localhost:7070/httpfileupload/B2KXSN8-WOLnMg_0r7--oaamaF0/logo_large.png"/>
<get url="http://localhost:7070/httpfileupload/B2KXSN8-WOLnMg_0r7--oaamaF0/logo_large.png"/>
</slot>
</iq>
fileSize 1678
loading : 0
loading : 100
1678
exception
relevant code:
private void uploadFile(File file) throws Exception {
SmackConfiguration.DEBUG = true;
XMPPTCPConnection connection = connectToServer(getUserName(), getPassword());
HttpFileUploadManager h = HttpFileUploadManager.getInstanceFor(connection);
h.discoverUploadService();
h.isUploadServiceDiscovered();
UploadProgressListener ul = new UploadProgressListener() {
@Override
public void onUploadProgress(long uploadedBytes, long totalBytes) {
long result = (uploadedBytes/totalBytes)*100;
System.out.println("loading : "+ result);
}
};
URL result = h.uploadFile(file,ul);
System.out.println(result);
}
HttpFileUploadManager:
private void upload(InputStream iStream, long fileSize, Slot slot, UploadProgressListener listener) throws IOException {
final URL putUrl = new URL(slot.getPutUrl().toString()+"/logo_large.png") ;
final XMPPConnection connection = connection();
final HttpURLConnection urlConnection = createURLConnection(connection, putUrl);
urlConnection.setRequestMethod("PUT");
urlConnection.setUseCaches(false);
urlConnection.setDoOutput(true);
urlConnection.setDoInput(true);
System.out.println("fileSize "+fileSize);
urlConnection.setFixedLengthStreamingMode(fileSize);
urlConnection.setRequestProperty("Content-Type", "application/octet-stream");
for (Map.Entry<String, String> header : slot.getHeaders().entrySet()) {
urlConnection.setRequestProperty(header.getKey(), header.getValue());
}
final SSLSocketFactory tlsSocketFactory = this.tlsSocketFactory;
if (tlsSocketFactory != null && urlConnection instanceof HttpsURLConnection) {
HttpsURLConnection httpsUrlConnection = (HttpsURLConnection) urlConnection;
httpsUrlConnection.setSSLSocketFactory(tlsSocketFactory);
}
try {
OutputStream outputStream = urlConnection.getOutputStream();
long bytesSend = 0;
if (listener != null) {
listener.onUploadProgress(0, fileSize);
}
BufferedInputStream inputStream = new BufferedInputStream(iStream);
// TODO Factor in extra static method (and re-use e.g. in bytestream code).
byte[] buffer = new byte[4096];
int bytesRead;
try {
while ((bytesRead = inputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, bytesRead);
bytesSend += bytesRead;
if (listener != null) {
listener.onUploadProgress(bytesSend, fileSize);
}
System.out.println(bytesSend);
}
}catch (Exception e) {
e.printStackTrace();
}
finally {
try {
outputStream.close();
} catch (Exception e) {
LOGGER.log(Level.WARNING, "Exception while closing output stream", e);
}
try {
inputStream.close();
}
catch (Exception e) {
LOGGER.log(Level.WARNING, "Exception while closing input stream", e);
}
}
XMPPTCPConnection c = (XMPPTCPConnection) connection();
int status = urlConnection.getResponseCode();
switch (status) {
case HttpURLConnection.HTTP_OK:
case HttpURLConnection.HTTP_CREATED:
case HttpURLConnection.HTTP_NO_CONTENT:
break;
default:
throw new IOException("Error response " + status + " from server during file upload: "
+ urlConnection.getResponseMessage() + ", file size: " + fileSize + ", put URL: "
+ putUrl);
}
}catch(Exception e) {
System.out.println("exception");
e.printStackTrace();
}finally {
urlConnection.disconnect();
}
}
the error occured on the following statement :
int status = urlConnection.getResponseCode();