Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I just downloaded C# SDK and ASP.NET MVC sample, modified it to work with 4.2.1. (web config facebookSettings parameters etc.), created my Facebook application and tried to run it. Click to facebook login button - ok, entering credentials into facebook popup - ok, allowing access for my application - ok, and then I get this error:

System.Net.Sockets.SocketException: An attempt was made to access a socket in a way forbidden by its access permissions 66.220.146.47:443

var app = new FacebookApp();
if (app.Session == null)
{
   // The user isnt logged in to Facebook
   // send them to the home page
   return RedirectToAction("Index");
}

// Get the user info from the Graph API
dynamic me = app.Api("/me"); // EXCEPTION THROWN HERE
ViewData["FirstName"] = me.first_name;
ViewData["LastName"] = me.last_name;

The app object is OK I think (containing settings params, session object with access token and my facebook userid, etc.)

I am using local development address http://myappdev.local (set to 127.0.0.1 in hosts file). The same address is set in my facebook app settings, also domain myappdev.local - Can this be the problem? I have seen examples using localhost:1234 in some tutorials.

like image 547
rouen Avatar asked Jan 25 '11 22:01

rouen


People also ask

What does an attempt was made to access a socket in a way forbidden by its access permissions mean?

The application is trying to open a port that is already used – One of the most common reasons why this error occurs is if you try to use an application that is configured to open a port that is already opened and actively used by a different service or application.


2 Answers

Not sure what all this was, but ipconfig /release && ipconfig /renew seemed to work for me.

like image 194
Michael W. Powell Avatar answered Oct 04 '22 05:10

Michael W. Powell


If you're getting the same error in Windows 8 development, it could be that you haven't enabled access over Private Networks in your Package.appxmanifest file:

Highlighting the Private Networks (Client & Server) option

like image 29
Robotnik Avatar answered Oct 04 '22 05:10

Robotnik