Skip to content

SocketException in Azure #12

@LarsBlaabjerg

Description

@LarsBlaabjerg

Hi,

I get a SocketException when using the UdpTraceListener in Azure (I changed the real IP/port in the trace below).

System.Net.Sockets.SocketException (0x80004005): An address incompatible with the requested protocol was used [::ffff:10.0.0.181]:9000
   at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Net.Sockets.Socket.Connect(EndPoint remoteEP)
   at System.Net.Sockets.Socket.Connect(IPAddress address, Int32 port)
   at Splunk.Logging.Util.OpenUdpSocket(IPAddress host, Int32 port) in c:\Users\Lars\Documents\Visual Studio 2013\Projects\splunk-library-dotnetlogging-master\src\Splunk.Logging.Common\Util.cs:line 36
   at Splunk.Logging.UdpTraceListener..ctor(IPAddress host, Int32 port) in c:\Users\Lars\Documents\Visual Studio 2013\Projects\splunk-library-dotnetlogging-master\src\Splunk.Logging.TraceListener\UdpTraceListener.cs:line 42
   at Splunk.Logging.UdpTraceListener..ctor(String host, Int32 port) in c:\Users\Lars\Documents\Visual Studio 2013\Projects\splunk-library-dotnetlogging-master\src\Splunk.Logging.TraceListener\UdpTraceListener.cs:line 50
   at Kiloo.PurchaseValidation.ServiceAPI.WebApiConfig.Register(HttpConfiguration config) in d:\BuildAgents\Thor\work\fa06a442553e9bbb\Kiloo.PurchaseValidation.ServiceAPI\App_Start\WebApiConfig.cs:line 27

The TcpTraceListener makes the process hang.

I found, that when creating the instance of System.Net.Sockets.Socket, if you specify the address family like this in Util.cs:

public static Socket OpenUdpSocket(IPAddress host, int port)
{
    var socket = new Socket(host.AddressFamily, SocketType.Dgram, ProtocolType.Udp);
    socket.Connect(host, port);
    return socket;
}

and like this in TcpSocketWriter.cs:

..
    try
    {
        var socket = new Socket(host.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
        socket.Connect(host, port);
        return socket;
    }
    catch (SocketException e)
...

Things work the way they should.

Hope you fix it soon as I'd rather use the "official" version than compile my own.

I'm using the following setup:
Library Version: Splunk.Logging.TraceListener 1.1.0 and Splunk.Logging.Common 1.1.0
Platform: Azure, not really sure about anything more specific than that.
Framework Version: .NET 4.5.1, Visual Studio Professional 2013
Splunk Version: 6.2.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions