You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by "Allan Schrum (JIRA)" <ji...@apache.org> on 2009/02/06 22:53:59 UTC

[jira] Updated: (AMQNET-135) Error in parsing composite Uri on Linux Mono

     [ https://issues.apache.org/activemq/browse/AMQNET-135?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Allan Schrum updated AMQNET-135:
--------------------------------

    Attachment: AMQNET-135-741308.diff

After checking into the code change required, I think it is a simple case of reprocessing the original URI that is passed. Before, the System.Uri.AbsoluteUri was used to reprocess the composite URI. This modification uses System.Uri.OriginalString if not .NET 1.0 or 1.1. Thus we should avoid the Mono problem (bug?) that changes double slashes into single slashes since we are using the original string and not the processed string.

Can you please test and let us know if this works? This patch also includes to patch to AMQNET-140.


> 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
>
>         Attachments: AMQNET-135-741308.diff
>
>
> 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.