Openfire 3.7.1 - Emojis in MUC kill chat connection


When you send an Emoji character to a MUC chat room (don’t know if this applies to “normal” chats, too) from your iPhone to a Openfire 3.7.1 server the connection is closed by the server.

Similar report under and in consequence as issue but due to the age of the thread, the different version and the different stacktrace I thought it might be not directly related.

Stacktrace for the error:

2012.10.30 15:49:36 org.jivesoftware.openfire.nio.ConnectionHandler - Closing connection due to error while processing message: ������

java.lang.NumberFormatException: For input string: “?”

at java.lang.NumberFormatException.forInputString(Unknown Source)

at java.lang.Integer.parseInt(Unknown Source)



at org.xmlpull.mxp1.MXParser.nextToken(




at org.jivesoftware.openfire.nio.ConnectionHandler.messageReceived(ConnectionHandl

at$TailFilter.messageReceived (



at$EntryImpl$1.messageReceive d(

at org.apache.mina.common.IoFilterAdapter.messageReceived(



at$EntryImpl$1.messageReceive d(


at org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecF



at$EntryImpl$1.messageReceive d(

at org.apache.mina.filter.executor.ExecutorFilter.processEvent( :239)

at org.apache.mina.filter.executor.ExecutorFilter$

at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

at java.util.concurrent.ThreadPoolExecutor$ Source)


at Source)

Best regards,


Sending emoji cut & pasted from (second block labelled “Emoticons”) will

disconnect the user. Tried with two different clients (Linux, not iPhone) so it seems to be a server problem.

The message does not reach the recipient.

1 Like

I have added this to the ticket comment.

1 Like

Same issue here. Any word on a fix?


line 159:Element doc = StringReader(stanza)).getRootElement();

to:Element doc = reader.parseDocument(stanza).getRootElement();

will fix this issue.

my question is i can’t insert emoji into database.

i use mysql and CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci,

when i insert emoji into database from JBOSS,it works fine,

but when i do the same thing from Openfire,i got this:

java.sql.SQLException: Incorrect string value: ‘\xF0\x9F\x98\x84\xF0\x9F…’ for column ‘name’ at row 1

help me out,thank you!

This answer is ambiguous, are you saying that doing the following:

in the file at line 159:

change this:

Element doc = StringReader(stanza)).getRootElement();

to this:

Element doc = reader.parseDocument(stanza).getRootElement();

will fix the Emoji issue?

yeh! You say I want to say.

Forgive my poor english!

Where exactly is that file to be found on a Windows system? Version 3.8.2 in the mean time. Thanks

He meant in the source code, not in the working binaries that you have installed. After changing the code Openfire have to be compiled again.


The better work around for this issue should modifying file, especially the Line 378/379:

((codePoint >= 0x20) && (codePoint <= 0xD7FF)) ||

((codePoint >= 0xE000) && (codePoint <= 0xFFFD)) ||

Merge the two conditions into one condition:

((codePoint >= 0x20) && (codePoint <= 0xFFFD)) ||

Not really an ideal fix, as it will allow many illegal characters to be exchanged, which may opens a DOS attack vector.

I’ve commited r13995 and r13996, which fixes the emoji problem for openfire and keeps the strictnes wrt illegal unicode characters in XMPP/XML.

Flow, thanks for your fix. Does it solve OF-455 ? If so, can you resolve the Jira issue?

Emojis work fine now, and the silly NumberFormatException bug is also fixed.

Not sure if OF-455 is the same cause, as it comes from Apache MINA. AFAIKT this it not what caused openfire to terminate the connection when emojis are send, which is fixed now.

It works fine, but if you restart the server go to the MUC the emoji doesn’t appear.

I am using mySQL. So maybe it has something to do with the way mySQL handles utf-8.