Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unsuccessful callback to https://..... due to HTTP status code 401 #7

Open
abelmagana88920 opened this issue Aug 26, 2016 · 9 comments

Comments

@abelmagana88920
Copy link

abelmagana88920 commented Aug 26, 2016

Sir, I have been setup the revalee service in my computer and also I used MVC C# Appllication to send request to Revalee, but when I visit the logs of my computer, it shows Unable to callback to https://..... due to HTTP status code 401.

@abelmagana88920 abelmagana88920 changed the title Unable to callback to https://..... due to HTTP status code 401 Unsuccessful callback to https://..... due to HTTP status code 401 Aug 26, 2016
@BrianMullin
Copy link

  1. Is the callback to an http: or an https: URL?
  2. What is the hostname and port of the MVC application? Is it running on the same computer as the Revalee Service?
  3. Does your local firewall/proxy software allow the Revalee Service to issue an outbound connection on that callback port?
  4. Does your MVC application accept anonymous (public) connections to the callback URL?
  5. Does your MVC controller action allow the POST method to the callback URL?

@abelmagana88920
Copy link
Author

abelmagana88920 commented Aug 29, 2016

tnx for the response.

this is my code where my mvc application calls Revalee service

   [AllowAnonymous]
    [HttpPost] 
    public JsonResult SendRequest(string customer_no)
    {


        JsonResult result;
        try
        {
            result = DataCSVXLS(customer_no);
            dynamic resultData = result.Data;
            string filePath = resultData.filePath;


           // Emails(customer_no, filePath);

           // FTPs(customer_no, filePath);

            return Json(result.Data, JsonRequestBehavior.AllowGet);
        }
        catch (Exception ex)
        {
            return Json(new { message = ex.Message });

        }
    }

public JsonResult RevaleeTest(string customer_no)
{

        string revaleeServiceHost = "localhost:46200";
        try
        {
            //var TimeS=TimeSpan.FromSeconds(5.0);
            var TimeS = DateTimeOffset.Now.AddMinutes(0.25);
            Uri expirationMessageCallbackUri = new Uri(
                string.Format("https://localhost:65369/Customer/SendRequest/NIC105", customer_no));

            Guid expirationMessageCallbackId = RevaleeRegistrar.ScheduleCallback(
                revaleeServiceHost, TimeS, expirationMessageCallbackUri);

            return Json(new { message = TimeS }, JsonRequestBehavior.AllowGet);

        }
        catch (Exception e)
        {
            return Json(new {message = e.Message}, JsonRequestBehavior.AllowGet);
        }
    }

1.) Is the callback to an http: or an https: URL?
The callback is call via http URL

2a.) What is the hostname and port of the MVC application?
The hostname is localhost and the port is 65369 but I used this port in development (currently in Microsoft Visual Studio). also I deployed my MVC Application to IIS where the port I used is 92.

2.b) Is it running on the same computer as the Revalee Service?
Yes. It is running in the same computer. I can see the Revalee Service in the Services and it is already started on local computer

3.) Does your local firewall/proxy software allow the Revalee Service to issue an outbound connection on that callback port?

How can I allow the Revalee Service to outbound connection?

4.) Does your MVC application accept anonymous (public) connections to the callback URL?
Yes I used [AllowAnonymous] in mVC Application

5.) Does your MVC controller action allow the POST method to the callback URL?
Yes I used [HttpPost] in mVC Application

@abelmagana88920
Copy link
Author

i Set the outbound connection on the Revalee Service and allow the port 92 and 65369 but still 401 status displayed in the logs

@BrianMullin
Copy link

  1. If you remove [HttpPost] from the SendRequest action temporarily and use your web browser to request https://localhost:65369/Customer/SendRequest/NIC105, then does the SendRequest action work properly?
  2. The Revalee Service is issuing the callback and needs to know if the callback was successful. Your callback action is returning a JsonResult. It needs to return an ActionResult. On success, the method should return a 200 OK HTTP result.
    return new HttpStatusCodeResult(HttpStatusCode.OK);

@abelmagana88920
Copy link
Author

abelmagana88920 commented Aug 29, 2016

1.) Yes, It works properly.
2.) I already modified the code, instead Public JsonResult RevaleeTest, I used Public ActionResult and return new HttpStatusCodeResult(HttpStatusCode.OK); but still 401 status displayed on the logs.

A few question
Why do we need this code in web.config

<revalee>
    <clientSettings serviceBaseUri="https://localhost:46200" authorizationKey="add_your_secret_key_here_012345678901234567890123456789"/>
    <recurringTasks callbackBaseUri="https://localhost:65369">
      <task periodicity="daily" hour="00" minute="00" url="/RevaleeTest"/>
      <task periodicity="hourly" minute="30" url="/RevaleeTest"/>
    </recurringTasks>

  </revalee>

I dont understand why authorization key is required.

@BrianMullin
Copy link

You assign a secret key so that you can ensure the callback action is only called by your pre-authorized callback requests.

Callback validation is automatically performed if you add the [CallbackAction] attribute to the callback method or use the following line programmatically:

if (!RevaleeRegistrar.ValidateCallback(this.Request))
{
...

@abelmagana88920
Copy link
Author

ok but why 401 status still displayed on the logs?

@abelmagana88920
Copy link
Author

It is ok if I remove the revalee tag in the web.config?

@BrianMullin
Copy link

You can remove the <revalee> tag from web.config, since you configured the required settings in your code. If you are not using recurring tasks, you should definitely not have that section in the web.config.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants