cancel
Showing results for 
Search instead for 
Did you mean: 

CIFS Sever / Samba server conflict; java.net.BindException:

erc
Champ in-the-making
Champ in-the-making
This is a report of my own experiments to obviate BindExceptions.
Having installed Alfresco on my Linux box, I was not really surprised to receive several
java.net.BindException: Address already in use
exceptions, as both Alfresco and my smbd/nmbd and ftp server were trying to bind to the same ports with the 'wildcard' IP address (0.0.0.0).

To allow co-existence, I decided to firstly, switch off the Alfresco netBIOSSMB service in favour of the Linux nmbd.  The method is described on other forum posts, all that is required is to edit WEB-INF/classes/alfresco/file-servers.xml (within alfresco.war) and force tcpipSMB:
Locate then lines:
      <tcpipSMB platforms="linux,solaris,macosx"/>
      <netBIOSSMB platforms="linux,solaris,macosx"/>
and remove linux from  the netBIOSSMB entry:
      <tcpipSMB platforms="linux,solaris,macosx"/>
      <netBIOSSMB platforms="solaris,macosx"/>

for the CIFS/smbd conflict, I decided to create an extra IP address just for Alfresco, and change the 'wildcard' IP bind address to a specific single address.
My original network interface was configured thus:

# ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 00:50:8D:F3:B4:71 
          inet addr:192.168.129.2  Bcast:192.168.129.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
[snip]

I added an extra IP address thus:
# ifconfig eth0:0 192.168.129.63
result:
# ifconfig eth0:0
eth0:0    Link encap:Ethernet  HWaddr 00:50:8D:F3:B4:71 
          inet addr:192.168.129.63  Bcast:192.168.129.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
[snip]

To force the smb daemon to listen on the correct address rather than wildcarding, I edited /etc/samba/smb.conf, and in the '[global]' section added:

; Allow several Samba servers on different subnet without conflicts
        socket address = 192.168.129.2
        interfaces = 192.168.129.0/255.255.255.0
        bind interfaces only = yes

consistent with my original eth0 ifconfig.

The similar task for the Alfresco CIFS server is accomplished by more editing of
WEB-INF/classes/alfresco/file-servers.xml
It is just a case of adding 'bindto' attributes in the correct spots and narrowing the broadcast address (necessary?)
For the CIFS Server, I changed the broadcast address to that of my LAN and added a bindto attribute below:

      <!– Set to the broadcast mask for the subnet –>
      <broadcast>192.168.129.255</broadcast>
      <bindto>192.168.129.63</bindto>

and added a simlar line for the Alfresco FTP Server:

   <config evaluator="string-compare" condition="FTP Server">
<!–      <debug flags="File,Search,Error,Directory,Info,DataPort"/> –>
      <bindto>192.168.129.63</bindto>
   </config>

The last task was to add a line to the /etc/hosts file in this and interested client machines, mapping the CIFS server name to its IP address:

192.168.129.63          brunel_a

Having then shutdown and restarted smb/nmb/alfresco, I was free of bind exceptions and my netstat output looked like this:

# netstat -lnp | egrep 'java|mb' | tr -s ' '
prot s r localAddress           remoteAddress state   PID/Program
tcp 0 0 192.168.129.2:139 0.0.0.0:* LISTEN 19409/smbd
tcp 0 0 192.168.129.63:21 0.0.0.0:* LISTEN 23187/java
tcp 0 0 192.168.129.2:7001 0.0.0.0:* LISTEN 23187/java
tcp 0 0 127.0.0.1:7001 0.0.0.0:* LISTEN 23187/java
tcp 0 0 192.168.129.63:445 0.0.0.0:* LISTEN 23187/java
tcp 0 0 192.168.129.2:445 0.0.0.0:* LISTEN 19409/smbd
udp 0 0 192.168.129.2:137 0.0.0.0:* 19414/nmbd
udp 0 0 192.168.129.2:137 0.0.0.0:* 19414/nmbd
udp 0 0 192.168.129.2:138 0.0.0.0:* 19414/nmbd
udp 0 0 0.0.0.0:138 0.0.0.0:* 19414/nmbd

7001 is my appserver's HTTP port.  The nearest equivalent command on MS Windows (or Unix) would be netstat -an.

Share browsing is now a bit iffy, I'm not sure why, but mounting/mapping of the network drives as \\brunel_a\Alfresco etc seems to work OK.

HTH

Regards

Eric Lee
1 REPLY 1

janco
Champ in-the-making
Champ in-the-making
Isnt there a easier way how to do this?
I am trying to get FTP working, but I am able to connect just from localhost not from outside.
Any suggestions?
Thanks
Jan