×

Discussion Board

Results 1 to 14 of 14
  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    15

    Question J2ME and problem with reconnection

    Hi all.
    I'm implemented a midlet able to create a p2p multihop network based on Bt devices.
    When application starts, the device search other devices into its range and then it create a connection with each one sending its routing table.
    Then, the behaviour of the device corrisponding to be a server.
    If I want to send a message, i push the button "SEND" on my device and i initialize a new connection to a device which behaviour is equal to a server.
    PROBLEM: in this phase an exception occurs showing "Can't connect"
    I' don't understanding this error!
    After the phase in which a device communcate to others its routing table, i close all connections and streams. But when i want to send a message an exception occurs! Do you say me..WHY????
    My code is at http://spazioinwind.libero.it/cgweb/java_source.zip
    I hope somebody will help me.
    Thanks!

    Roberto

  2. #2
    Nokia Developer Expert
    Join Date
    Jun 2005
    Posts
    923

    Re: J2ME and problem with reconnection

    Hi Palermo4Ever,

    As far as I can remember, JME applications on Nokia phones do not support multiple incoming connections, so if you trying to do this, that's probably the reason you're seeing this error.

    Also, the service discovery transactions are limited to 1 at a time, so that may be the reason as well.

    Daniel

  3. #3
    Registered User
    Join Date
    May 2006
    Posts
    15

    Question Re: J2ME and problem with reconnection

    Hi dcrocha,

    i don't want multiple connection.
    I connect one client at time to the server.
    The server accept only one connection, receive data and close streams and connection, while only one client open a connection to the server, send data and close streams and connection.
    As reguard as the service discovery transaction, i verify that this phase is ok: no problems
    I hope my explanation is easy to understand
    thank u

  4. #4
    Nokia Developer Expert
    Join Date
    Jun 2005
    Posts
    923

    Re: J2ME and problem with reconnection

    So if I understood correctly, your midlet:

    - On startup, connects to a series of devices and sends them its routing table, one at a time, closing streams and connection every time.
    - You can get one of the devices on the list and send them a message, but this time, you can't connect, is that right? If so, what kind of exception do you have? Are the other midlets on the other phones started and waiting for connections?

    Daniel

  5. #5
    Registered User
    Join Date
    May 2006
    Posts
    15

    Re: J2ME and problem with reconnection

    Hi Daniel,

    your abstract is good.
    When i want to send a message to a device that's waiting for connections an IOException occurs.
    I think is a problem of services registrattion. Whten the server accept connections the service registration is ok. But when i call service.close() ,where service is a StreamConnectionNotifier object, the service registration change and that could be the cause of my problem. what do u think about this suppose?
    laters

    Roberto

  6. #6
    Nokia Developer Expert
    Join Date
    Jun 2005
    Posts
    923

    Re: J2ME and problem with reconnection

    Hi Palermo4Ever,

    The problem is there. You cannot close the StreamConnectionNotifier, as it also closes the service. You have to close the StreamConnection that is obtained from the notifier with the acceptAndOpen() call.

    Perhaps you want to check this article: http://today.java.net/pub/a/today/20...bluetooth.html or this Forum Nokia document: http://www.forum.nokia.com/info/sw.n..._v1_0.zip.html

    Both contain example code, and the Forum Nokia document contains also a .jar file you can install in your phone to test the connection.

    Daniel

  7. #7
    Registered User
    Join Date
    May 2006
    Posts
    15

    Re: J2ME and problem with reconnection

    Hi dcrocha,

    instead I think could be a problem of connection close because i cannot send more than one message from the same client, but if i run another client i can send the first message. So, the service is discovered.
    I think that i cannot send more than one message from the same client beacuse the connection don't close!!!!
    Is this possible? I also think that could be a problem of communicatin among the threads. What do u think about this suppose?

  8. #8
    Registered User
    Join Date
    Mar 2003
    Posts
    4,105
    Who tells you, closing a RFCOMM (or L2CAP) channel like you are doing, closes the Baseband connection at the same time? In the Java Bluetooth API (JSR-82 version 1.0 and 1.1) you have no such control and there is no guarantee such a strategy will overcome the overall limitations of your Bluetooth chips.

    Forget that project and tell your supervisor it does not make sense.

    Which devices are you using anyway? If you really, really want to track this down, buy a Bluetooth-on-air protocol analyzer and check the states of all your nodes.
    Last edited by traud; 2011-05-12 at 08:58.

  9. #9
    Registered User
    Join Date
    May 2006
    Posts
    15

    Re: J2ME and problem with reconnection

    So, cannot I close the connection?

  10. #10
    Registered User
    Join Date
    Mar 2003
    Posts
    4,105
    You can close connections like the Streams and RFCOMM or L2CAP and you should do so. However, at least the Bluetooth Baseband connection cannot be controlled. From my experience on Nokia devices, the Baseband connection closes some seconds after all connections "on top" have been closed. Nevertheless, I use RFCOMM connections. There it is not possible to control the L2CAP connection closing. Perhaps, if you go for L2CAP connections, you can close at least that one directly and the Baseband closes along of it. Although from my overall Bluetooth experience, I doubt this will solve it.

    For testing my theory, simply wait a minute between your (successful) first message and closed connections. Then re-open the connection and send the second message. If that works now, you have a good indication my explanation might be correct.

  11. #11
    Registered User
    Join Date
    May 2006
    Posts
    15

    Re: J2ME and problem with reconnection

    Quote Originally Posted by traud
    For testing my theory, simply wait a minute between your (successful) first message and closed connections. Then re-open the connection and send the second message. If that works now, you have a good indication my explanation might be correct.
    Hi traud,
    i use RFCOMM too. I tried your solution but it doesn't work: i sent the first message and i waited for two minutes and no good results appeared.
    I think that could be a problem of communication between threads. What do you think about this conclusion?
    Thanks a lot for your help

  12. #12
    Registered User
    Join Date
    May 2006
    Posts
    15

    Re: J2ME and problem with reconnection

    Hi Traud,

    I solve the problem of reconnection deleting the line as reguard as the closing of the StreamConnectionNotifier object. Indeed, when i call the method close(), client cannot find the service on the server. In this case, i could search again available service. So, i would like detele each record of the SDDB withous closing the notifier the a connection is terminated.
    so, how can i delete records of the SDDB without closing notifier?
    Thank you so much

  13. #13
    Registered User
    Join Date
    Mar 2003
    Posts
    4,105
    Sorry, I do not understand your post. Could you please try again?

  14. #14
    Registered User
    Join Date
    May 2006
    Posts
    15

    Re: J2ME and problem with reconnection

    ok traud,
    i solved my problems!
    it was a problem of inizialization of the notifier
    Thanks for your counsils!

Similar Threads

  1. J2ME: Problem in Nokia Solution for a software problem
    By mte01 in forum Mobile Java Tools & SDKs
    Replies: 4
    Last Post: 2011-06-08, 05:52
  2. Obfuscator problem for J2ME polish
    By rudyanto in forum Mobile Java General
    Replies: 0
    Last Post: 2006-05-29, 14:06
  3. J2ME Wireless Toolkit 2.2 & Series 60 MIDP SDK problem
    By schmooz in forum Mobile Java Tools & SDKs
    Replies: 2
    Last Post: 2005-11-28, 22:26
  4. J2ME: Problem in Nokia Solution for a media problem
    By mte01 in forum Mobile Java Tools & SDKs
    Replies: 0
    Last Post: 2005-08-12, 11:30
  5. MIDI Sound problem (J2ME / Series 60)
    By JPapke in forum Mobile Java Media (Graphics & Sounds)
    Replies: 2
    Last Post: 2004-10-29, 08:17

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×