IT Community - Software Programming, Web Development and Technical Support

Exception "security block" while connecting to bluetooth device

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 ...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Software Development > Mobile Software Development

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 11-10-2007, 02:53 AM
S.Vinothkumar S.Vinothkumar is offline
D-Web Genius
 
Join Date: May 2007
Posts: 1,061
S.Vinothkumar is on a distinguished road
Default Exception "security block" while connecting to bluetooth device

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!
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 11-10-2007, 02:55 AM
amansundar amansundar is offline
D-Web Analyst
 
Join Date: May 2007
Posts: 325
amansundar is on a distinguished road
Default Re: Exception "security block" while connecting to bluetooth device

hi,

did u find a solution to come over that problem.
__________________
cheers
Aman
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 11-10-2007, 02:57 AM
krishnakumar krishnakumar is offline
D-Web Analyst
 
Join Date: May 2007
Posts: 206
krishnakumar is on a distinguished road
Default Re: Exception "security block" while connecting to bluetooth device

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
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 11-10-2007, 02:58 AM
leoraja8 leoraja8 is offline
D-Web Sr.Programmer
 
Join Date: May 2007
Posts: 194
leoraja8 is on a distinguished road
Default Re: Exception "security block" while connecting to bluetooth device

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."
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 11-10-2007, 03:00 AM
saloni srivatsava saloni srivatsava is offline
D-Web Trainee
 
Join Date: Sep 2007
Posts: 16
saloni srivatsava is on a distinguished road
Default Re: Exception "security block" while connecting to bluetooth device

I have the same problem on a K600. But my device is never out of range so the exception don't seem to be a range problem.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 11-10-2007, 03:01 AM
amansundar amansundar is offline
D-Web Analyst
 
Join Date: May 2007
Posts: 325
amansundar is on a distinguished road
Default Re: Exception "security block" while connecting to bluetooth device

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.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 11-10-2007, 03:05 AM
mobilegeek mobilegeek is offline
D-Web Analyst
 
Join Date: Jun 2007
Posts: 205
mobilegeek is on a distinguished road
Default Re: Exception "security block" while connecting to bluetooth device

Does this happen when you wait (a lot of time), too? I think the Bluetooth Baseband has to close first and this, you cannot control in JSR-82.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 11-10-2007, 03:07 AM
S.Vinothkumar S.Vinothkumar is offline
D-Web Genius
 
Join Date: May 2007
Posts: 1,061
S.Vinothkumar is on a distinguished road
Default Re: Exception "security block" while connecting to bluetooth device

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!
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 11-10-2007, 03:09 AM
amansundar amansundar is offline
D-Web Analyst
 
Join Date: May 2007
Posts: 325
amansundar is on a distinguished road
Default Re: Exception "security block" while connecting to bluetooth device

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
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 11-10-2007, 03:11 AM
mobilegeek mobilegeek is offline
D-Web Analyst
 
Join Date: Jun 2007
Posts: 205
mobilegeek is on a distinguished road
Default Re: Exception "security block" while connecting to bluetooth device

No idea left except to buy a (very expensive) on-air Bluetooth packet logger and debug it.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #11 (permalink)  
Old 11-10-2007, 03:13 AM
amansundar amansundar is offline
D-Web Analyst
 
Join Date: May 2007
Posts: 325
amansundar is on a distinguished road
Default Re: Exception "security block" while connecting to bluetooth device

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
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #12 (permalink)  
Old 11-10-2007, 03:15 AM
leoraja8 leoraja8 is offline
D-Web Sr.Programmer
 
Join Date: May 2007
Posts: 194
leoraja8 is on a distinguished road
Default Re: Exception "security block" while connecting to bluetooth device

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!
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #13 (permalink)  
Old 11-10-2007, 03:17 AM
saloni srivatsava saloni srivatsava is offline
D-Web Trainee
 
Join Date: Sep 2007
Posts: 16
saloni srivatsava is on a distinguished road
Default Re: Exception "security block" while connecting to bluetooth device

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.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #14 (permalink)  
Old 11-10-2007, 03:19 AM
latchu latchu is offline
D-Web Trainee
 
Join Date: Sep 2007
Posts: 21
latchu is on a distinguished road
Default Re: Exception "security block" while connecting to bluetooth device

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?
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


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


All times are GMT -7. The time now is 10:08 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0