LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-13-2017, 01:55 PM   #1
srama
LQ Newbie
 
Registered: Oct 2017
Posts: 5

Rep: Reputation: Disabled
Can't create RFCOMM TTY: Address already in use


I listen for a Bluetooth connection in my server doing:

Code:
rfcomm listen rfcomm1 1
Then I connect with my Bluetooth client and this message appears:

Code:
Connection from XX:XX:XX:XX:XX:XX to /dev/rfcomm1
Press CTRL-C for hangup
This means that everything is alright...

Then I finish my connection by doing Ctrl+C in the server or in the client.

After this, I do again:

Code:
rfcomm listen rfcomm1 1
But this time, when I connect the client I receive this message:

Code:
Can't create RFCOMM TTY: Address already in use
So I go and I check which connections are open:
Code:
rfcomm -a
And I can see that the connection appears, as closed, but should not appear once disconnected...

Code:
rfcomm1: XX:XX:XX:XX:XX:XX -> XX:XX:XX:XX:XX:XX channel 1 closed [reuse-dlc release-on-hup ]
The strangest thing is that sometimes, disconnection is successful and I can reconnect without any problem at all.
 
Old 10-18-2017, 09:10 PM   #2
ordealbyfire83
Member
 
Registered: Oct 2006
Location: Leiden, Netherlands
Distribution: LFS, Ubuntu Hardy
Posts: 302

Rep: Reputation: 89
I have noticed similar behavior as well. Something is not right. I was using "rfcomm connect ..." to establish a connection to a bluetooth device, and I would say roughly a third of the time it either did not work or said the device was still in use after closing the connection.

To work around this I edited the file /etc/bluetooth/rfcomm and added an entry for my device using something like this

Code:
rfcomm0 {
     #Automatically bind the device at startup
     bind yes;

     # Bluetooth address of the device
     device XX:XX:XX:XX:XX:XX;

     # RFCOMM channel for the connection
     channel 1;

     # Description of the connection
     comment "Name of Device";
}
Of course you should alter the rfcomm number if you don't want to call it rfcomm0, and specify the proper channel if necessary (otherwise try 1). Now to initialize the connection

Code:
sudo rfcomm bind 0
Note, the "0" is for rfcomm0, not the channel. Then when you are finished,

Code:
sudo rfcomm release 0
I don't know what is different about doing it this way as opposed to using "rfcomm connect ..." but this way seems to work a bit more reliably for some reason.
 
Old 10-19-2017, 09:36 AM   #3
srama
LQ Newbie
 
Registered: Oct 2017
Posts: 5

Original Poster
Rep: Reputation: Disabled
I have asked this question in other forums and they have proposed similar solutions... I pass you the link:

https://stackoverflow.com/questions/...already-in-use

Thanks

Last edited by srama; 10-19-2017 at 09:42 AM.
 
Old 10-20-2017, 10:19 PM   #4
ordealbyfire83
Member
 
Registered: Oct 2006
Location: Leiden, Netherlands
Distribution: LFS, Ubuntu Hardy
Posts: 302

Rep: Reputation: 89
Yeah. Using bind / release in this case would be a workaround and not a solution. A proper solution would be to have "rfcomm connect" work as it should. I would suggest filing a bug report against the BlueZ package through your distribution.

If anyone does know of a proper solution or patch, I would certainly like to know as well. I often have to tear down rfcomm connections or even restart the bluetooth daemon in order to get things working.

You mention using bluetooth in a server to listen for connections. If you do not necessarily know what bluetooth devices are in the vicinity, then adding them to rfcomm.conf in advance would definitely be problematic. If this is the case you could try writing a script to automate this - run "hcitool scan" to get the MAC address(es), i.e. parse this output and add these devices to rfcomm.conf. Certainly inconvenient, but might work.

Also judging from your response in your other link, you may not know the proper channel. I don't know the reliability of connecting to multiple channels at once - you would need "sdptool browse" to find the proper channel for what you are trying to connect for. I cannot really guide you in how to do this, because I don't know what kind of channels you need. (For example, sdbtool tells me that my phone can broadcast NMEA data on Channel 5, so when I want to see GPS info I add channel 5 in rfcomm.conf.)

Another thought - does your server's bluetooth chip use closed firmware? That might have something to do with those TIOCGSERIAL issues, though that's probably a kernel ( > 3.6 ) problem. Then again, you say that when a device connects fine, you still see that message.

Last edited by ordealbyfire83; 10-20-2017 at 10:43 PM.
 
Old 10-21-2017, 02:05 PM   #5
srama
LQ Newbie
 
Registered: Oct 2017
Posts: 5

Original Poster
Rep: Reputation: Disabled
Quote:
You mention using bluetooth in a server to listen for connections. If you do not necessarily know what bluetooth devices are in the vicinity, then adding them to rfcomm.conf in advance would definitely be problematic. If this is the case you could try writing a script to automate this - run "hcitool scan" to get the MAC address(es), i.e. parse this output and add these devices to rfcomm.conf. Certainly inconvenient, but might work.
This can work but I prefer to remove the connection properly.

Quote:
Also judging from your response in your other link, you may not know the proper channel. I don't know the reliability of connecting to multiple channels at once - you would need "sdptool browse" to find the proper channel for what you are trying to connect for. I cannot really guide you in how to do this, because I don't know what kind of channels you need. (For example, sdbtool tells me that my phone can broadcast NMEA data on Channel 5, so when I want to see GPS info I add channel 5 in rfcomm.conf.)
I create my own services with sdptool. I have an script that removes the default services, then creates others with serial profile. Also I change the Uuid of every sdptool service I create, so they can be distinguished separately from the Android device (client). When this is done, I do as many "rfcomm listen" as services I have.

I do this because from Android, the way of connecting to a bluetooth service is by Uuid, not by channel number. The number of the channel doesn't really matter.

Quote:
Another thought - does your server's bluetooth chip use closed firmware? That might have something to do with those TIOCGSERIAL issues, though that's probably a kernel ( > 3.6 ) problem. Then again, you say that when a device connects fine, you still see that message.
I have tried with other bluetooth devices and the problem is still there...
 
Old 10-24-2017, 11:50 AM   #6
srama
LQ Newbie
 
Registered: Oct 2017
Posts: 5

Original Poster
Rep: Reputation: Disabled
SOLUTION

https://stackoverflow.com/questions/...-use/46915801#
 
  


Reply



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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
/dev/tty: No such device or address ? Answer Ram Kankanampati Linux - General 2 09-21-2011 03:55 AM
T38Modem can't create pseudo tty's mstjohn1974 Linux - Networking 3 10-24-2009 10:49 AM
cpio: /dev/tty: No such device or address dougbourne Linux - Server 6 10-09-2008 12:28 PM
/dev/tty: No such device or address ? dkennedy Linux - General 2 08-01-2006 11:28 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:44 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration