Fix thread problem with fx and premature socket closing

The jf client dropped connections and failed to display messages that it received.

After these changes everything worked fine on both client and server side.