I have a strange bug in my midlet. Each of the mobile phone must be client and server at the same time (via a Bluetooth connection). The problem is that sometimes (almost one out of ten tries), the server acts strangely. The server thread hangs on :
streamconnection = streamconnectionnotifier.acceptAndOpen();
(this is normal) but when a client tries to connect with :
streamconnection = (StreamConnection)Connector.open(connString);
the server hangs for 5 seconds (the mobile phone is totally frozen for 5 seconds), then the client throws an IOException whose message is "Connection rejected". The server doesn't throw an exception, it still waits for a client to connect.
I have tried lots of things, but this problem still exists. As each mobile acts as a client and as a server at the same time, there could be the problem, but I have read a lot of Bluetooth documentation and I can't find where.
May someone point me in the right direction to debug this ? Any idea is welcome !
Thank you very much !