Hi Team
i am trying to connect openfire server with websocket using 4.5.0 alpha1 lib from past 1 week but unable to connect.
Dont know how can i make connection, send and receive messages in case of websocket.
could you please provide me any example or give me direction.
my code
Blockquote
DomainBareJid serviceName = JidCreate.domainBareFrom(“1054.com”);
EntityBareJid user = JidCreate.entityBareFrom(“manu@1054.com”);
ModularXmppClientToServerConnectionConfiguration.Builder builder = ModularXmppClientToServerConnectionConfiguration.builder();
builder.removeAllModules().setXmppDomain(serviceName)
.setSendPresence(true)
.setHost(“localhost”)
.setSecurityMode(SecurityMode.disabled)
;
builder.setXmppAddressAndPassword(user, “password”);
//handshakeHttps();
// Set a fallback uri into websocket transport descriptor and add this descriptor into connection builder.
XmppWebSocketTransportModuleDescriptor.Builder websocketBuilder = XmppWebSocketTransportModuleDescriptor.getBuilder(builder);
websocketBuilder.explicitlySetWebSocketEndpointAndDiscovery(new URI(“ws://1054.com:7070/ws/”), false);
builder.addModule(websocketBuilder.build());
ModularXmppClientToServerConnectionConfiguration config = builder.build();
ModularXmppClientToServerConnection connection = new ModularXmppClientToServerConnection(config);
connection.setParsingExceptionCallback(new ExceptionThrowingCallbackWithHint());
connection.connect();
final String messageBody = ": Hello from the other side!";
Message message = connection.getStanzaFactory().buildMessageStanza()
.to("sandeep@1054.com")
.setBody(messageBody)
.build();
connection.login();
connection.sendStanza(message);
connection.disconnect();
Please help.
This code i got from below link
https://github.com/igniterealtime/Smack/blob/master/smack-repl/src/main/java/org/igniterealtime/smack/smackrepl/WebSocketConnection.java
i am getting below error
Blockquote
Oct 14, 2020 7:08:06 PM org.jivesoftware.smack.AbstractXMPPConnection parseAndProcessNonza
SEVERE: Unknown nonza: {urn:ietf:params:xml:ns:xmpp-framing}open
Oct 14, 2020 7:08:06 PM 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 14, 2020 7:08:06 PM 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 14, 2020 7:08:06 PM 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 14, 2020 7:08:06 PM 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.
Oct 14, 2020 7:08:06 PM org.jivesoftware.smackx.xdata.provider.DataFormProvider parseField
WARNING: The Field ‘admin-addresses’ from FORM_TYPE ‘http://jabber.org/network/serverinfo’ is not registered. Field type is unknown, assuming text-single.
Oct 14, 2020 7:08:06 PM com.openfire.controller.ExceptionThrowingCallbackWithHint handleUnparsableStanza
WARNING: Parsing exception encountered. This exception will be re-thrown, leading to a disconnect. You can change this behavior by setting a different ParsingExceptionCallback using setParsingExceptionCallback(). More information an be found in AbstractXMPPConnection’s javadoc.
Oct 14, 2020 7:08:11 PM 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 14, 2020 7:08:11 PM 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 14, 2020 7:08:11 PM 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 14, 2020 7:08:11 PM 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.
Oct 14, 2020 7:08:11 PM org.jivesoftware.smackx.xdata.provider.DataFormProvider parseField
WARNING: The Field ‘admin-addresses’ from FORM_TYPE ‘http://jabber.org/network/serverinfo’ is not registered. Field type is unknown, assuming text-single.
Oct 14, 2020 7:08:11 PM com.openfire.controller.ExceptionThrowingCallbackWithHint handleUnparsableStanza
WARNING: Parsing exception encountered. This exception will be re-thrown, leading to a disconnect. You can change this behavior by setting a different ParsingExceptionCallback using setParsingExceptionCallback(). More information an be found in AbstractXMPPConnection’s javadoc.
Oct 14, 2020 7:08:16 PM org.jivesoftware.smackx.httpfileupload.HttpFileUploadManager$2 authenticated
WARNING: Error during discovering HTTP File Upload service
org.jivesoftware.smack.SmackException$NoResponseException: No response received within reply timeout. Timeout was 5000ms (~5s). StanzaCollector has been cancelled. Waited for response using: IQReplyFilter: iqAndIdFilter (AndFilter: (OrFilter: (IQTypeFilter: type=error, IQTypeFilter: type=result), StanzaIdFilter: id=MNUZB-3)), : fromFilter (OrFilter: (FromMatchesFilter (full): 1054.com)).
** at** org.jivesoftware.smack.SmackException$NoResponseException.newWith(SmackException.java:124)
at org.jivesoftware.smack.SmackException$NoResponseException.newWith(SmackException.java:104)
at org.jivesoftware.smack.StanzaCollector.nextResultOrThrow(StanzaCollector.java:281)
at org.jivesoftware.smack.StanzaCollector.nextResultOrThrow(StanzaCollector.java:228)
at org.jivesoftware.smackx.disco.ServiceDiscoveryManager.discoverInfo(ServiceDiscoveryManager.java:606)
at org.jivesoftware.smackx.disco.ServiceDiscoveryManager.discoverInfo(ServiceDiscoveryManager.java:578)
at org.jivesoftware.smackx.disco.ServiceDiscoveryManager.findServicesDiscoverInfo(ServiceDiscoveryManager.java:813)
at org.jivesoftware.smackx.disco.ServiceDiscoveryManager.findServicesDiscoverInfo(ServiceDiscoveryManager.java:781)
at org.jivesoftware.smackx.disco.ServiceDiscoveryManager.findServicesDiscoverInfo(ServiceDiscoveryManager.java:761)
at org.jivesoftware.smackx.httpfileupload.HttpFileUploadManager.discoverUploadService(HttpFileUploadManager.java:192)
at org.jivesoftware.smackx.httpfileupload.HttpFileUploadManager$2.authenticated(HttpFileUploadManager.java:129)
at org.jivesoftware.smack.AbstractXMPPConnection.callConnectionAuthenticatedListener(AbstractXMPPConnection.java:1706)
at org.jivesoftware.smack.AbstractXMPPConnection.afterSuccessfulLogin(AbstractXMPPConnection.java:797)
at org.jivesoftware.smack.c2s.ModularXmppClientToServerConnection.access$2800(ModularXmppClientToServerConnection.java:89)
at org.jivesoftware.smack.c2s.ModularXmppClientToServerConnection$AuthenticatedAndResourceBoundState.transitionInto(ModularXmppClientToServerConnection.java:909)
at org.jivesoftware.smack.c2s.ModularXmppClientToServerConnection.attemptEnterState(ModularXmppClientToServerConnection.java:420)
at org.jivesoftware.smack.c2s.ModularXmppClientToServerConnection.walkStateGraphInternal(ModularXmppClientToServerConnection.java:350)
at org.jivesoftware.smack.c2s.ModularXmppClientToServerConnection.walkStateGraph(ModularXmppClientToServerConnection.java:292)
at org.jivesoftware.smack.c2s.ModularXmppClientToServerConnection.walkStateGraphInternal(ModularXmppClientToServerConnection.java:372)
at org.jivesoftware.smack.c2s.ModularXmppClientToServerConnection.walkStateGraph(ModularXmppClientToServerConnection.java:292)
at org.jivesoftware.smack.c2s.ModularXmppClientToServerConnection.walkStateGraphInternal(ModularXmppClientToServerConnection.java:372)
at org.jivesoftware.smack.c2s.ModularXmppClientToServerConnection.walkStateGraph(ModularXmppClientToServerConnection.java:292)
at org.jivesoftware.smack.c2s.ModularXmppClientToServerConnection.walkStateGraphInternal(ModularXmppClientToServerConnection.java:372)
at org.jivesoftware.smack.c2s.ModularXmppClientToServerConnection.walkStateGraph(ModularXmppClientToServerConnection.java:292)
at org.jivesoftware.smack.c2s.ModularXmppClientToServerConnection.loginInternal(ModularXmppClientToServerConnection.java:269)
at org.jivesoftware.smack.AbstractXMPPConnection.login(AbstractXMPPConnection.java:643)
at org.jivesoftware.smack.AbstractXMPPConnection.login(AbstractXMPPConnection.java:600)
at com.openfire.controller.OpenfireXMPPWebSocketClient.main(OpenfireXMPPWebSocketClient.java:61)
Oct 14, 2020 7:08:16 PM org.jivesoftware.smack.websocket.okhttp.OkHttpWebSocket disconnect
INFO: WebSocket has been closed with message: WebSocket closed normally