Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Dennis Zille 5 posts 25 karma points
    Jul 24, 2015 @ 07:15
    Dennis Zille
    0

    Error when using Umbraco task scheduler

    Hi all,

    I am trying to use the Umbraco task scheduler in Umbraco 7.2.8. Each time the scheduler tries to run the task an exception is being thrown.

    The task in the umbracoSettings.config file looks like this:

    <scheduledTasks>
    <task log="true" alias="test60" interval="60" url="http://localhost:53373/umbraco/api/Test/TestMethod"/></scheduledTasks>
    

    The url which is called doesn't seem to matter. The same exception will always be thrown.

    This is the exception which gets thrown:

     2015-07-24 08:57:42,203 [6] ERROR Umbraco.Web.Scheduling.ScheduledTasks - [P6828/T1/D2] An error occurred calling web task for url: http://localhost:53373/umbraco/api/Test/TestMethod
    System.Net.ProtocolViolationException: Cannot send a content-body with this verb-type.
       bei System.Net.HttpWebRequest.CheckProtocol(Boolean onRequestStream)
       bei System.Net.HttpWebRequest.BeginGetRequestStream(AsyncCallback callback, Object state)
       bei System.Net.Http.HttpClientHandler.StartGettingRequestStream(RequestState state)
       bei System.Net.Http.HttpClientHandler.PrepareAndStartContentUpload(RequestState state)
    --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
       bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       bei System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
       bei Umbraco.Web.Scheduling.ScheduledTasks.d__9.MoveNext() 

    When I am using an older version e.g. 7.2.0 The scheduler works fine and the url gets called.

    Thanks for any help

    Dennis

  • Dennis Zille 5 posts 25 karma points
    Jul 27, 2015 @ 06:45
    Dennis Zille
    0

    Hi all,

    so I looked a little bit further into the problem and the scheduler works fine for me until version 7.2.6. After that the above mentioned exception gets thrown.

    It seems the exception gets thrown in this method in the ScheduledTasks class of Umbraco:

    
    private async Task GetTaskByHttpAync(string url, CancellationToken token)
            {
                using (var wc = new HttpClient())
                {
                    var request = new HttpRequestMessage()
                    {
                        RequestUri = new Uri(url),
                        Method = HttpMethod.Get,
                        Content = new StringContent(string.Empty)
                    };

                //TODO: pass custom the authorization header, currently these aren't really secured!
                //request.Headers.Authorization = AdminTokenAuthorizeAttribute.GetAuthenticationHeaderValue(_appContext);
    
                try
                {
                    var result = await wc.SendAsync(request, token);
                    return result.StatusCode == HttpStatusCode.OK;
                }
                catch (Exception ex)
                {
                    LogHelper.Error<ScheduledTasks>("An error occurred calling web task for url: " + url, ex);
                }
                return false;
            }
        }
    

    GitHub Link to Source Code:

    https://github.com/umbraco/Umbraco-CMS/blob/dev-v7/src/Umbraco.Web/Scheduling/ScheduledTasks.cs

    The question for me is, am I doing something wrong or is it a problem Umbraco?

    Thanks for any help

    Dennis

  • Steve Bentley 21 posts 64 karma points
    Aug 17, 2015 @ 15:41
    Steve Bentley
    0

    Hi Dennis,

    I'm seeing exactly the same problem in 7.2.8, have you had any luck solving the issue?

    Thanks

    Steve

  • Dennis Zille 5 posts 25 karma points
    Aug 18, 2015 @ 06:43
    Dennis Zille
    0

    Hi Steve,

    not really, no.

    Altough I found out, that if you change the line:

    var result = await wc.SendAsync(request, token);
    

    to:

    var result = await wc.GetAsync(url);
    

    in the method I mentioned in my previous post, the scheduler seems to work again.

  • Steve Bentley 21 posts 64 karma points
    Aug 18, 2015 @ 06:50
    Steve Bentley
    0

    Thanks Dennis,

    I'll give that a go.

  • David Verberckmoes 46 posts 77 karma points
    Aug 18, 2015 @ 13:11
    David Verberckmoes
    0

    Hi,

    The Method for the HttpRequestMessage should be HttpMethod.Post instead of HttpMethod.Get, see MSDN.

  • Dennis Zille 5 posts 25 karma points
    Aug 18, 2015 @ 14:33
    Dennis Zille
    0

    Hi David,

    that's what I suspected as well.

    So it seems to be a bug in Umbraco.

  • Steve Bentley 21 posts 64 karma points
    Aug 19, 2015 @ 13:19
    Steve Bentley
    0

    Do you know if anyone has raised an issue for this, because it looks like it is still in the code in the 7.3 betas.

  • Dennis Zille 5 posts 25 karma points
    Aug 19, 2015 @ 14:27
    Dennis Zille
    0

    No, not as far as I know.

  • David Verberckmoes 46 posts 77 karma points
    Aug 19, 2015 @ 14:45
    David Verberckmoes
    0

    Created an issue: U4-6990

  • Sanjay Sen 30 posts 94 karma points
    Sep 24, 2015 @ 15:24
    Sanjay Sen
    0

    Hi here,

    Is there a way I can get it fixed in version 7.2.8 ? I don't want to upgrade to 7.3.0 since I have a live site running with this version.

    Thanks

  • Deepak 14 posts 34 karma points
    Sep 28, 2015 @ 10:14
    Deepak
    0

    Hello All,

    I am also facing same issue. Is anyone have fix for this issue ?

    Thanks in Advance!

    Deepak

  • Andrew Ellis-chadwick 4 posts 104 karma points
    Oct 05, 2015 @ 10:32
    Andrew Ellis-chadwick
    0

    Iv create a section to not only take over the scheduler but also to give you an area to organise them easily in the admin area.

    url-task-scheduler-for-v7

    So not a fix but a work around :)

  • Nguyen Hien 52 posts 133 karma points
    Jan 08, 2016 @ 14:34
    Nguyen Hien
    0

    How can I see backoffice of your Url Task Scheduler For V7? I can't see and screen of this package?

  • Nguyen Hien 52 posts 133 karma points
    Jan 15, 2016 @ 04:39
    Nguyen Hien
    0

    I upgraded to umbraco 7.3.4 all schedule work well now.

  • Bo Jacobsen 140 posts 802 karma points
    5 days ago
    Bo Jacobsen
    0

    Did anyone find a solution to this, other than upgrade?

    I just upgraded a solution to 7.2.8 and now i got this error.

    I can fix the unpublish task by setting the umbracoApplicationUrl="https://www.domain.com/umbraco" in the web.routing in umbracoSettiongs.config file. but it does not fix added tasks.

Please Sign in or register to post replies

Write your reply to:

Draft