[ 
https://issues.apache.org/jira/browse/DIRMINA-386?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12503019
 ] 

Kenji Hollis edited comment on DIRMINA-386 at 6/8/07 10:58 PM:
---------------------------------------------------------------

If this is done, the problem here is that the IOException will "ignore" the 
socket connect.  If that happens, the call on line 89 (DEFAULT_REUSE_ADDRESS = 
socket.getReuseAddress(); in this case) will cause an IO Exception, and the 
entire initializer will fail.  The whole point of this initializer is to make 
the class usable; if the call fails, there *has* to be a failsafe put in place 
to account for the problem.

I would say to put the entire block of code from lines 89 to 95 in a try/catch 
block, and use a default raw Socket() instead of a connection to a ServerSocket 
if the initial lookup causes an IO Exception.  This allows programs that rely 
on MINA can actually run without having to shut themselves down, leaving the 
user/programmer scratching their heads.

If Linux is indeed giving faux vaules when initializing a raw Socket, then the 
failsafe should be put in place.  Worst case scenario, the programmer will have 
to change the values using the Bean, but then, the Bean allows entry points to 
get/set those values.  But in this case, the code *should* initialize 
regardless of the method used - if the socket fails to initialize, the 
application will effectively be useless.

Can we reach a compromise here?  I've tried about a dozen different 
combinations to get this code to work when overriding the sun.com.dns provider 
settings, and nothing works.  Using a raw Socket is the only thing that I've 
found that works properly.


 was:
If this is done, the problem here is that the IOException will "ignore" the 
socket connect.  If that happens, the call on line 89 (DEFAULT_REUSE_ADDRESS = 
socket.getReuseAddress(); in this case) will cause an IO Exception, and the 
entire initializer will fail.  The whole point of this initializer is to make 
the class usable; if it isn't, there *has* to be a failsafe put in place to 
account for the problem.

I would say to put the entire block of code from lines 89 to 95 in a try/catch 
block, and use a default raw Socket() instead of a connection to a 
ServerSocket, so programs that rely on MINA can actually run without having to 
shut themselves down, leaving the user/programmer scratching their heads.

If Linux is indeed giving faux vaules when initializing a raw Socket, then the 
failsafe should be put in place.  Worst case scenario, the programmer will have 
to change the values using the Bean, but then, the Bean allows entry points to 
get/set those values.  But in this case, the code *should* initialize 
regardless of the method used - if the socket fails to initialize, the 
application will effectively be useless.

Can we reach a compromise here?

> SocketSessionConfigImpl: initialize() uses "localhost" to bind 
> InetSocketAddress, should use IP instead
> -------------------------------------------------------------------------------------------------------
>
>                 Key: DIRMINA-386
>                 URL: https://issues.apache.org/jira/browse/DIRMINA-386
>             Project: MINA
>          Issue Type: Bug
>          Components: Transport
>    Affects Versions: 1.0.3, 1.1.0
>         Environment: JDK 5/6, Linux, Windows, Solaris
>            Reporter: Kenji Hollis
>             Fix For: 1.0.4, 1.1.1
>
>
> The main issue here is if a programmer has decided to override the DNS 
> entries, or run the MINA software in a firewalled environment (where DNS is 
> firewalled, for instance), MINA will throw an "Unresolved Host" IO Exception 
> at line 66 of SocketSessionConfigImpl.java.  This can flat-out be re-created 
> every time by simply overriding the DNS entry on the local machine to 
> 127.0.0.1 (resolv.conf).
> Because the "initialize()" function simply binds to localhost to retrieve 
> socket configuration defaults, there is a better way to approach this.  This 
> method has been tested, and is known to work.
> Instead of binding to localhost, bind to "127.0.0.1" or "0.0.0.0" as the 
> address.  Binding to 127.0.0.1 will do the exact same thing, effectively, as 
> looking up localhost.  Ultimately, this will be a FASTER initialization, as 
> it needs to resolve "localhost" to an IP.  By giving the system an IP address 
> to begin with, we resolve this issue.
> What I did was created a local private static final String called 
> "LOCALHOST_ADDRESS" in the top area of the class, and set it to 127.0.0.1.  I 
> then modified line 66 to use LOCALHOST_ADDRESS, as well as line 73 to use 
> LOCALHOST_ADDRESS on the socket.connect.
> At the company I work for, we were able to recreate the issue of the code NOT 
> working, and the code WORKING.  By modifying the code to use localhost as 
> 127.0.0.1 or 0.0.0.0, we got around the DNS lookup failure, and MINA fired 
> right up happily.
> I recommend this fix be added in the next release - both major and minor - 
> for MINA.  The company I work for is doing performance testing with MINA now, 
> and we may be using it to replace the main socket functionality if all goes 
> well.  I would like to see this fix in the next milestone release if at all 
> possible.
> If you need a patch file provided, I would be more than happy to give one!

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to