An attempt was made to access a socket in a way forbidden by its access permissions 127.0.0.1:10002

Hello Experts,

I am getting following socket error while calling in Azure Web App Service

Structuremap registry :

public class IocRegistry : Registry
{
public IocRegistry()
{ var endpointInstance = GetEndPointInstance();
For().Use(endpointInstance).Singleton();
}

public IEndpointInstance GetEndPointInstance() {

        var applicationQueueName = ConfigurationManager.AppSettings["ApplicationQueueName"].ToString();
        var endpointConfiguration = new EndpointConfiguration(applicationQueueName);

        endpointConfiguration.ConfigureBus();
        endpointConfiguration.ConfigureRegistry();
        endpointConfiguration.Configure();

        var endpointInstance = Endpoint.Start(endpointConfiguration).GetAwaiter().GetResult();
        return endpointInstance;
    }

Locally it works fine but Azure KUDU gives me

[SocketException (0x271d): An attempt was made to access a socket in a way forbidden by its access permissions 127.0.0.1:10002]
System.Net.Sockets.Socket.InternalEndConnect(IAsyncResult asyncResult) +7007812
System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult) +84
System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception) +256

[WebException: Unable to connect to the remote server]
System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult, TransportContext& context) +316
System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult) +14
Microsoft.WindowsAzure.Storage.Core.Executor.Executor.EndGetRequestStream(IAsyncResult getRequestStreamResult) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Core\Executor\Executor.cs:144

[StorageException: Unable to connect to the remote server]
Microsoft.WindowsAzure.Storage.Core.Executor.Executor.EndExecuteAsync(IAsyncResult result) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Core\Executor\Executor.cs:51
Microsoft.WindowsAzure.Storage.Table.CloudTable.EndCreate(IAsyncResult asyncResult) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Table\CloudTable.cs:1131
Microsoft.WindowsAzure.Storage.Table.CloudTable.EndCreateIfNotExists(IAsyncResult asyncResult) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Table\CloudTable.cs:1286
Microsoft.WindowsAzure.Storage.Core.Util.<>c__DisplayClass2`1.b__0(IAsyncResult ar) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Core\Util\AsyncExtensions.cs:69
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +99

You’re using Azure Storage Persistence or Azure Storage Queues transport with the connection string from your local environment, pointing to the emulator. You need to use a connection string associated with a real storage account.

Thanks, it worked. Connection string was trying to connect my local dev box.