AnsweredAssumed Answered

How to define FCM server properly

Question asked by Manish on Jan 4, 2017
Latest reply on Jan 5, 2017 by Bosleo

Using 4.2-rc1 (java) I create a connection to Firebase Cloud Messaging (FCM) with configuration:

 

XMPPTCPConnection.setUseStreamManagementResumptionDefault(true);
XMPPTCPConnection.setUseStreamManagementDefault(true);
XMPPTCPConnectionConfiguration.Builder config = XMPPTCPConnectionConfiguration.builder();
config.setHostAddress(InetAddress.getByName(server));
config.setPort(port);
config.setSecurityMode(ConnectionConfiguration.SecurityMode.ifpossible);
config.setSendPresence(false);
config.setSocketFactory(SSLSocketFactory.getDefault());
config.setXmppDomain(domain);
connection = new XMPPTCPConnection(config.build());

 

This throws an error:

 

Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -1

  at java.lang.String.charAt(String.java:658)

  at org.jivesoftware.smack.util.dns.HostAddress.<init>(HostAddress.java:48)

  at org.jivesoftware.smack.util.dns.HostAddress.<init>(HostAddress.java:62)

 

Apparently this is because HostAddress is calling a constructor (line 48) with a string as "" - which can never work because the constructor operates on the string:

 

if(fqdn.charAt(fqdn.length() - 1) == 46) {

 

I guess this is a bug to be resolved, but is there a workaround?

Outcomes