Answered by:
Attempting to Send data to Event Hub - No connection could be made because the target machine actively refused it

Question
-
Found this simple piece of code that *should* send an event to my Event hub. The connection string is good and no matter what I've tried it comes back to the exception getting thrown on client.Send(data).
I've read a few places that corporate firewalls can get in the way but I'm pretty sure port 5671 is open. We followed the 'Service Bus Events Hub' article exactly and it gives us the same error. I'm going to try at home tonight but was wondering if this is a common error for people getting started.Dim connectionString As String = ConfigurationManager.AppSettings("EventsHubManage.ConnectionString") Dim builder As New ServiceBusConnectionStringBuilder(connectionString) builder.TransportType = TransportType.Amqp Dim factory As MessagingFactory = MessagingFactory.CreateFromConnectionString(builder.ToString()) Dim client As EventHubClient = factory.CreateEventHubClient("mecpieventhub") Dim data As New EventData(Encoding.UTF8.GetBytes("Hello"))
client.Send(data)
- Edited by Andy Gould Tuesday, February 3, 2015 11:03 PM code reformatting
Tuesday, February 3, 2015 11:02 PM
Answers
-
Can you do a basic TCP connection test from your client machine to your service name?
Use telnet client (if telnet is missing you can install it from add/remove programs > Turn Windows Features On/Off) and try to open a connection by running below command:
Telnet >open <yournamespace>.servicebus.windows.net 5671
If this test fails then you have a networking issue.
- Proposed as answer by Will ShaoMicrosoft employee Sunday, February 15, 2015 8:28 AM
- Marked as answer by Will ShaoMicrosoft employee Tuesday, February 17, 2015 2:18 AM
Tuesday, February 3, 2015 11:19 PM
All replies
-
Can you do a basic TCP connection test from your client machine to your service name?
Use telnet client (if telnet is missing you can install it from add/remove programs > Turn Windows Features On/Off) and try to open a connection by running below command:
Telnet >open <yournamespace>.servicebus.windows.net 5671
If this test fails then you have a networking issue.
- Proposed as answer by Will ShaoMicrosoft employee Sunday, February 15, 2015 8:28 AM
- Marked as answer by Will ShaoMicrosoft employee Tuesday, February 17, 2015 2:18 AM
Tuesday, February 3, 2015 11:19 PM -
Good idea, I tested this in behind my corp firewall and outside using Powershell, it worked outside and failed behind the firewall. I got confirmation from a network guy that outbound 5671 is blocked.
1. telnet <namespace>.servicebus.windows.net 5671
Connecting To <namespace>.servicebus.windows.net...Could not open connection to the host, on port 5671: Connect failed
2. New-Object Net.Sockets.Tcpclient("<namespace>.servicebus.windows.net",5671)
"No connection could be made because the target machine actively refused it 23.99.128.69:5671"
Thanks for the pointer!
Wednesday, February 4, 2015 2:12 PM -
Hi Andy,
From your description, I am not sure you already set the rules for your event hub. I suggest you could refer to this document for more details:
https://msdn.microsoft.com/en-us/library/azure/dn790190.aspx and this tutorials:
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.Thursday, February 12, 2015 8:04 AM