[ 
https://issues.apache.org/activemq/browse/AMQNET-135?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=49193#action_49193
 ] 

Allan Schrum commented on AMQNET-135:
-------------------------------------

I looked at RFC 2396 at http://www.rfc-editor.org/rfc/rfc2396.txt which deals 
with URI specifications. To support a failover URI which would include embedded 
URI of the failover hosts, we must use opaque URI (those which do not start 
with a leading slash). Otherwise we would need to escape all the contextually 
illegal characters found within the authority or path segments of an absolute 
URI. Thus, an acceptable URI for failover operation would be:

failover:(tcp://localhost:61616,tcp://localhost:61626,tcp://localhost:61636?param=true)?something=anything

In this mode, all the characters following "failover:" are opaque and should 
not be processed by System.Uri with the expectation that a host and path 
portion will be found. Unfortunately, Windows .NET 2.0 does not process an 
opaque URI very well, and Mono seems to edit its processing. Since we are using 
URI correctly (from the RFC point-of-view) the above sample should be what we 
use for failover operation. Since System.Uri does not support this type of URI 
very well, we will need to parse this more carefully in a more manual mode 
without relying upon System.Uri for the parsing of the outer failover: scheme.

Do you concur? If so, than I can take a look at seeing if I can modify the code 
to operate in this fashion.

> Error in parsing composite Uri on Linux Mono
> --------------------------------------------
>
>                 Key: AMQNET-135
>                 URL: https://issues.apache.org/activemq/browse/AMQNET-135
>             Project: ActiveMQ .Net
>          Issue Type: Bug
>          Components: ActiveMQ Client
>    Affects Versions: 1.1
>         Environment: 1. ActiveMQ on linux CentOS 4.4
> 2. Client on Mono 1.9 on linux CentOS 4.4
>            Reporter: Tomasz Wiczling
>            Assignee: Jim Gomes
>            Priority: Critical
>             Fix For: 1.1
>
>
> I'm using ActiveMQ .Net to connect to ActiveMQ from Mono application on linux.
> I've downloaded new (12-12-2008, rev. 726083) version of ActiveMQ .Net and 
> started from testing new feature: FAILOVER transport.
> First test made on Windows were very promising, but trying to run my 
> application on linux caused an error.
> I've invested it a bit and found out this:
> On linux Mono the System.Uri constructor causes error while parsing composite 
> uri, because it replaces all '//' with '/'. And tries to connect to 
> 'tcp:/localhost:61616' for example.
> I've tested it on newest Mono 2.0 SUSE with the same result.
> Uris, I've tried:
> failover:(tcp://192.168.44.244:61616)
> failover:(tcp://192.168.44.244:61616)/
> failover://localhost/(tcp://192.168.44.244:61616)
> failover://localhost/(tcp://192.168.44.244:61616)/
> All with the same result :((
> Illustration.
> I modified Apache.NMS.ActiveMQ.ConnectionFactory constructors as below:
> (...)
>               public ConnectionFactory(string brokerUri, string clientID)
>                       : this(new Uri(brokerUri), clientID)
>               {
>                       Tracer.Debug("ConnectionFactory(string brokerUri, 
> string clientID): brokerUri='" + brokerUri + "'");
>               }
> (...)
>               public ConnectionFactory(Uri brokerUri, string clientID)
>               {
>                       Tracer.Debug("ConnectionFactory(Uri brokerUri, string 
> clientID): brokerUri='" + brokerUri + "'");
>                       this.brokerUri = brokerUri;
>                       this.clientId = clientID;
>               }
> (...)
> and prepare simple islustrating program:
> using System;
> using Apache.NMS;
> using Apache.NMS.ActiveMQ;
> namespace IssueExample
> {
>       internal class ConsoleTracer : ITrace
>       {
>               public bool IsDebugEnabled { get { return true; } }
>               public bool IsInfoEnabled { get { return true; } }
>               public bool IsWarnEnabled { get { return true; } }
>               public bool IsErrorEnabled { get { return true; } }
>               public bool IsFatalEnabled { get { return true; } }
>               public void Debug(string message) { Console.WriteLine("DEBUG:" 
> + message); }
>               public void Info(string message) { Console.WriteLine("INFO:" + 
> message); }
>               public void Warn(string message) { Console.WriteLine("WARN:" + 
> message); }
>               public void Error(string message) { Console.WriteLine("ERROR:" 
> + message); }
>               public void Fatal(object message) { Console.WriteLine("FATAL:" 
> + message); }
>       }
>       class Program
>       {
>               public static void Main(string[] args)
>               {
>                       Tracer.Trace = new ConsoleTracer();
>                       IConnectionFactory factory = new 
> ConnectionFactory(args[0]);
>                       IConnection connection = factory.CreateConnection();
>                       connection.Close();
>                       Console.WriteLine("Connected and Disconnected 
> successfully to '" + args[0] + "'");
>                       Console.ReadKey();
>               }
>       }
> }
> Running my program the output was:
> # mono IssueExample.exe 
> failover://localhost/\(tcp://192.168.44.244:61616\,tcp://192.168.44.244:61616\)/
> DEBUG:ConnectionFactory(Uri brokerUri, string clientID): 
> brokerUri='failover://localhost/(tcp:/192.168.44.244:61616,tcp:/192.168.44.244:61616)/'
> DEBUG:ConnectionFactory(string brokerUri, string clientID): 
> brokerUri='failover://localhost/(tcp://192.168.44.244:61616,tcp://192.168.44.244:61616)/'
> DEBUG:Reconnect was triggered but transport is not started yet. Wait for 
> start to connect the transport.
> DEBUG:Started.
> DEBUG:Creating reconnect task
> DEBUG:Waking up reconnect task
> INFO:Waiting for transport to reconnect.
> DEBUG:Attempting connect to: tcp:/192.168.44.244:61616
> DEBUG:Opening socket to:  on port: -1
> DEBUG:Connect fail to: tcp:/192.168.44.244:61616, reason: 
> System.ArgumentOutOfRangeException: Argument is out of range.
> Parameter name: Invalid port
>   at System.Net.IPEndPoint.set_Port (Int32 value) [0x00000]
>   at System.Net.IPEndPoint..ctor (System.Net.IPAddress address, Int32 port) 
> [0x00000]
>   at Apache.NMS.ActiveMQ.Transport.Tcp.TcpTransportFactory.Connect 
> (System.String host, Int32 port) [0x00000]
>   at Apache.NMS.ActiveMQ.Transport.Tcp.TcpTransportFactory.CompositeConnect 
> (System.Uri location) [0x00000]
>   at Apache.NMS.ActiveMQ.Transport.TransportFactory.CompositeConnect 
> (System.Uri location) [0x00000]
>   at Apache.NMS.ActiveMQ.Transport.Failover.FailoverTransport.doReconnect () 
> [0x00000]
> DEBUG:Waiting 10 ms before attempting connection.
> (...)
> <Infinit loop of reconnects>

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