This is a discussion on Exception "security block" while connecting to bluetooth device within the Mobile Software Development forums, part of the Software Development category; I have an application that continously polls data from a bluetooth serial port connection (btspp://). Sometimes when the connection to ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| I have an application that continously polls data from a bluetooth serial port connection (btspp://). Sometimes when the connection to the bluetooth device is lost, the application is unable to reconnect again the Connection.open method throws an IOException("security block"). I may fx I loose connection when the device gets out of range from the phone, a K750i. I then try to reconnect by creating 1) closing all open io connections to the old connection, and 2) create a new connection to the device. Normally that procedure is successful, but sometimes it fails and I receive a IOException with the succinct message "security block". What does the exception "security block" mean, and is there anything I can do to avoid it? I have looked through the developer bluetooth samples, but I cannot see any relevant difference from the way I use the connection. I also have the latest firmware upgrade: R1AA008.
__________________ S.VinothkumaR Behind me is infinite power, Before me is Endless Possibility, Around me is Boundless Opportunity, Why should I fear! |
| Sponsored Links |
| |||
| I am also having the same problem - occasionally after losing the connection the client can no longer connect to the server with the security block exception occuring. The problem seems to be in the server as if i reboot this device then then the client can connect fine. There is obviously something I am not closing or resetting correctly but it is strange how its only happening occasionally. Any suggestions?
__________________ Krishnakumar.S Beware of Everything -that is un true; stick to the Truth shall succeed slowly but steadily |
| |||
| If you carefully examine the exception you see its actually an BluetoothConnectionExpetion, BluetoothConnectionException (JSR 82 Bluetooth API and OBEX API) And according to the javadocs the "security block" means: Indicates the connection failed because the security settings on the local device or the remote device were incompatible with the request. Though I have noticed that you get this exception when the actual device is out of range. I have some code that are using connects to detect if a device is in proximity or not. The reason to do it with a connect is because I drop any connection if I do a discovery, while i do not drop other connections while attempting connecting a device. Anyway shouldn't the exception rather be Timeout instead when a device is not in range? Reading the docs it sounds like the one to expect: "Indicates the connection to the server failed due to a timeout." |
| |||
| I have the same problem with a K800i. Start server, start client, first connection... all ok. both server and client, close the Connection (server close StreamConnectionNotifier too), next, restart server conn (not app!), restart client conn, client throws "security block" ! So, the first connection don't make problem, all next connections make a "security block" until the application server be closed and restarted. And I don't have any idea how to fix the problem ![]() These are the server and client codes to make connection url: (if there are any security problem, the problem is in these codes) ---------------------------------------------------------- // Server Code:
LocalDevice.getLocalDevice().setDiscoverable( DiscoveryAgent.GIAC );
StringBuffer url = new StringBuffer();
url.append("btspp://localhost:");
url.append( BToothInitServer.SERVER_UUID.toString() );
url.append(";authenticate=false");
url.append(";authorize=false");
url.append(";encrypt=false");
url.append(";name=" + BToothInitServer.SERVER_NAME );
notifier = (StreamConnectionNotifier) Connector.open( url.toString() ); // Client Code: String url = clientServiceRecord.getConnectionURL(ServiceRecord.NOAUTHENTICATE_NOENCRYPT, false); conn = (StreamConnection) Connector.open(url); ----------------------------------------------------------
__________________ cheers Aman Last edited by amansundar : 11-10-2007 at 03:04 AM. |
| |||
| In my application I only wait 10 seconds before I try to reconnect. Sometimes it works other times not. Haven't really noticed any pattern yet. Does anyone have any suggestions on how long to wait before trying to reconnect....
__________________ S.VinothkumaR Behind me is infinite power, Before me is Endless Possibility, Around me is Boundless Opportunity, Why should I fear! |
| |||
| If i wait a lot of time (about 15 minutes) between first and second connection, the second throws that exception. I've tried with a System.gc() too... but the problem still appears.
__________________ cheers Aman |
| |||
| I've tried some experiments: (two mobiles: my SE k800i and a SE k750i of a friend of mine) ---------------------------------- Experiment 1: - k800i in listening mode (server) - k750i connects to server (client) First connection: ok Second and more connections: error ---------------------------------- Experiment 2: - k750i in listening mode (server) - k800i connects to server (client) First, second and more connections: ok ! ---------------------------------- Experiment 3: - k800i server+client app - k750i server+client app Setting k800i to server, k750i to client ..first time: ok ..second and more: error Swtich (k750i server, k800i client) ..ok..ok..ok.. Switch (k800i server, k750i client) ..ok..error..error.. Swtich (k750i server, k800i client) ..ok..ok..ok.. Switch (k800i server, k750i client) ..ok..error..error.. Swtich (k750i server, k800i back to main manu and do nothing) Switch (k800i server, k750i client) ..error...error... ----------------------------- So, it seems that this problem appears only for certain products. And, after I started my k800i the application, when I connect to another server, this solve the problem for one connection. The error appears only for two sequentially server accept!
__________________ cheers Aman |
| |||
| Hi everybody, I would like to know if somebody found a solution for this problem! I have got the same problem like amansundar, but my bluetooth server is an J2SE application wich is waiting incoming connections from J2ME mildet clients. At the first time, the connection between the server and my K610i establish, but if i deconnect the K610i, and try to reconnect it, i receive a "Security block" exception. I must deconnect and reconnect the server application to establish a new connection. (I use "Avetana" library for my server application) Can you help me please? Thank you! |
| |||
| Hi I think that this forum is trying to solve two different problems. For the server problem when only the first connection can be established I think could be a SDP problem and it is described at: Advice on managing connections between Bluetooth SDP records and a game server How ever I also have problems with the Bluetooth that occasionally stops working and forces me to restart the phone to be able to reconnect the Bluetooth connection. I have a background midlet that reads data from a Bluetooth GPS and sends it to a server. This works fine but in some time between 8-72 hours the Bluetooth hangs and I have to restart the phone. The exception that is thrown is a “security block”. How ever that exception can be thrown earlier and don't block the communication. So what I can se the security exception does not always lead to a blocked connection. I would appreciate any ideas about this. |
| |||
| Hi all! I am also having the same behaviour as saloni srivatsava. Are there really not anyone that has come up with some kind of work-around other than rebooting the phone? ... or maybe a link to some other useful ressources on this matter? |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How can we block "Right click-refresh" option on a web-page? | GDevakii | HTML, CSS and Javascript Coding Techniques | 1 | 09-25-2007 02:35 AM |
| I keep getting "Data Missing" when I click the "back" button in my browser. How can I | oxygen | HTML, CSS and Javascript Coding Techniques | 1 | 07-28-2007 01:12 AM |
| Diffrence between a "assignment operator" and a "copy constructor" | Sabari | C and C++ Programming | 1 | 07-24-2007 05:00 AM |
| Why do I get "HTTP 500" error(or "(DLL)initialization routine failed")in my browser? | kingmaker | ASP and ASP.NET Programming | 1 | 07-20-2007 04:38 AM |
| Difference between a "assignment operator" and a "copy constructor"? | vigneshgets | C and C++ Programming | 2 | 07-12-2007 05:30 AM |