Results 1 to 20 of 20

Thread: Ajax Unknown error

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2013
    Posts
    65
    Thanks
    4
    Thanked 3 Times in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Question Ajax Unknown error

    [edit]
    In QtWebKit often occurs error "Unknown error" in Ajax requests of type POST
    This problem does not occur in conventional browsers (like Google Chrome and Firefox).

    It would be possible to create a "DEBUG" all requests that occur within the "QWebView" to analyze the cause of the problem?

    bq. Note: There is always occurring, but still quite frequently

    Ignore is part:
    Is it a bug in QT?
    What would be the best way around the problem?

    I believe that it is not something simple to discover, would analyze the requests of QtWebKit (using QtWebKit itself) made ​​by Ajax (not the console QWebInspector, I've tried this and did not help me)?
    Last edited by brcontainer; 19th July 2013 at 20:33.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Ajax Unknown error

    It would be possible to create a "DEBUG" all requests that occur within the "QWebView" to analyze the cause of the problem?
    Qt Code:
    1. webView->page()->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
    To copy to clipboard, switch view to plain text mode 
    In your web view window Right-click and select Inspect and you get access to a wealth of tools to debug your script including inspecting all the network exchanges and any console log output your script makes. I don't how this could not help debug your problem.

    You can always watch the entire network exchange using Wireshark or Fiddler

  3. #3
    Join Date
    Apr 2013
    Posts
    65
    Thanks
    4
    Thanked 3 Times in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Question Re: Ajax Unknown error

    as I said earlier, QWebInspector not work, just returns "QWebInspector" has no details.

    not the console QWebInspector, I've tried this and did not help me
    Thanks for trying, but is there any way to do this than with QWebInspector?

    [edit]
    Fiddler2 capture ajax GoogleChrome but fails to capture the QWebView.

    [edit]
    Fiddler2 uses proxy (local proxy), so the error does not occur, because practically the page has already been generated.
    Last edited by brcontainer; 20th July 2013 at 01:54.

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Ajax Unknown error

    What do you mean "just returns "QWebInspector"? Invoking the web inspector opens a separate window containing debugging tools. Since you are adamant that the internal tool "does not work" then you have limited yourself to external tools.

    Fiddler will not "capture the QWebView" if the QWebView is not configured to use the system proxy (or Fiddler direct). If your software behaves differently talking through a non-caching proxy then that sounds like another problem to solve.

  5. #5
    Join Date
    Apr 2013
    Posts
    65
    Thanks
    4
    Thanked 3 Times in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Question Re: Ajax Unknown error

    Thanks for the quick reply.

    Fiddler2 uses proxy (local proxy), so the error does not occur, because practically the page has already been generated (by localhost).

    When I said QWebInspector, I was referring to the same console (I was writing or revised what I typed was so confused, sorry).
    In the tab "network", the only message that returns me is: "Unknown error", as I already said.

    What I would like to know:

    I'm thinking of creating a local server ("proxy") inside the "project" and set the application to use the proxy, would it be viable (when used proxy (fiddler) stopped the error occurs)?

    Or have another way to generate the pages, rebuild the requests and send the QtWebKit?
    Last edited by brcontainer; 20th July 2013 at 13:53.

  6. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Ajax Unknown error

    Fiddler2 uses proxy (local proxy), so the error does not occur, because practically the page has already been generated (by localhost).
    Huh? Your Ajax request passes through the proxy to the upstream host, and the response comes back from the upstream host via the proxy. The proxy host does not create anything new in the payload and, in the case of Fiddler, it also does not change or cache anything.

    Both Fiddler and the Network panel in the web inspector show you the content of your request (headers, data payload) and the content of the response (headers and data payload). I can only assume that the "Unknown error" string you refer to is the payload of the response. That comes from the remote host, it's not generated Qt, Qt WebKit or Fiddler. It is most likely the result of sending a malformed request and this would generally be visible as difference between a working request and a failing one. We have no way to know.

  7. #7
    Join Date
    Apr 2013
    Posts
    65
    Thanks
    4
    Thanked 3 Times in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Ajax Unknown error

    I do not know if I did not understand you, or you do not understand me (I refer to my last post).

    Yes I believe it is something malformed, but I believe it has to do with the QtWebKit (or something parecidog), which sends data "truncated" (or something similar) to the server. When using proxy "Fiddler2", who made the request to the server is was "Fiddler2" and not the "QWebView" with this error "xxxx" stopped happening.

    Therefore I believe that the best way to solve the problem is to create a "thread" in my project that is a local server, the local server is a proxy and I would set up so that the application runs only with the local proxy (Thread).

    What I wonder, is another way (besides the "local proxy") requests to recreate the QWebView (QtWebKit)?

    For example: is how to handle the "QNetworkRequest" of "QtWebKit"?

    Thanks.

  8. #8
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Ajax Unknown error

    QtWebKit uses an instance of QNetworkAccessManager you can replace with a customised one. see the QWebPage docs. No threads required. Threads rarely simplify a problem anyway.

    The best way to solve the problem is to stop guessing. Look at the raw request that is actually sent. Look at the logs on the server. Look at the raw headers ( not the payload ) of the response. Compare to a good one. Check your Javascript for common errors. If you build and send a request in C++ make sure you are doing it correctly with the server-expected Content-Type and encoding. Make sure objects relevant to send requests are staying in-scope long enough to send the request. Ask questions accompanied with relevant information about behaviours you do not understand. Stop assuming QtWebKit is making some magical change to the request just to spite you. Ultimately if XmlHttpRequest or the Javascript engine was fundamentally broken then there would be a lot more people than just you with issues.
    Last edited by ChrisW67; 21st July 2013 at 22:34.

  9. #9
    Join Date
    Apr 2013
    Posts
    65
    Thanks
    4
    Thanked 3 Times in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Question Re: Ajax Unknown error

    QtWebKit uses an instance of QNetworkAccessManager you can replace with a customised one.
    Sorry, I'm a beginner, do not know how to replace the instance, could help me?

    ------------------

    even so I used to generate a Wire LOG apparently everything is normal.

    The error occurred in the request line: 560
    Qt Code:
    1. POST /testXhr.php?teste=13 HTTP/1.1
    2. Accept: */*
    3. Referer: http://localhost/testXhr.php
    4. Origin: http://localhost
    5. X-Requested-With: XMLHttpRequest
    6. User-Agent: Mozilla/5.0 (Windows;) AppleWebKit/537.21 (KHTML, like Gecko) Safari/537.21
    7. Content-Type: application/x-www-form-urlencoded; charset=UTF-8
    8. Content-Length: 5
    9. Connection: Keep-Alive
    10. Accept-Encoding: gzip, deflate
    11. Accept-Language: pt-BR,en,*
    12. Host: localhost
    13.  
    14. ok=13
    To copy to clipboard, switch view to plain text mode 

    Download the complete LOG:
    http://www.mediafire.com/download/b9.../log-full.pcap

    PrintScreen:
    xhr-erro-on-qt.jpg

    Javascript Code:
    Qt Code:
    1. window.delta=0;
    2. window.running = true;
    3. function run(){
    4. ++window.delta;
    5. $.ajax({
    6. 'type':'POST',
    7. 'url':"testXhr.php?teste="+(window.delta),
    8. 'data':'ok='+(window.delta),
    9. 'success':function(data){ },
    10. 'error':function(a,b,c){
    11. console.log([a,b,c]);
    12. window.running = false;
    13. },
    14. 'complete':function(a,b){
    15. console.log(b);
    16. setTimeout(function(){
    17. if(window.running){
    18. run();
    19. }
    20. },500);
    21. }
    22. });
    23. }
    24. window.onload=run;
    To copy to clipboard, switch view to plain text mode 

    Please help me with this.
    Last edited by brcontainer; 22nd July 2013 at 03:04.

  10. #10
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Ajax Unknown error

    My copy of Wireshark 1.8.8 and tcpdump claim your 24620 byte pcap file is corrupt. I see five exchanges, the last of which is a POST that I don't see a response for.

  11. #11
    Join Date
    Apr 2013
    Posts
    65
    Thanks
    4
    Thanked 3 Times in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Question Re: Ajax Unknown error

    Log WireShark:
    http://www.mediafire.com/download/fz...-wireshark.zip

    I tried to analyze the LOG,
    I realized that the request failed ("unknown error")
    Request failed:
    Qt Code:
    1. POST /testXhr.php?teste=3 HTTP/1.1
    To copy to clipboard, switch view to plain text mode 
    In wireshark shows that the data arrived normally see in the picture, the contents usually arrived:
    print-wire.jpg

    Note: I used the website for a client, by any chance you want to test the operation of the script, I'm currently without website for online tests.
    [edit]
    I know you said you stay in this guessing no use,
    but I suppose the problem is with some "timeout" (or similar) within the framework of the "QT" making requests.


    Help me please.
    Last edited by brcontainer; 23rd July 2013 at 01:21.

Similar Threads

  1. QHostInfo - Unknown Error
    By alurchi in forum Qt Programming
    Replies: 7
    Last Post: 17th May 2011, 11:59
  2. QNetworkAccessManager unknown error
    By lipk in forum Newbie
    Replies: 2
    Last Post: 20th March 2011, 13:38
  3. python qt4 unknown fatal error
    By izghitu in forum Newbie
    Replies: 0
    Last Post: 25th January 2011, 19:54
  4. QSslsocket and Unknown error
    By szarek in forum Qt Programming
    Replies: 21
    Last Post: 14th October 2010, 14:20
  5. QimageReader Unknown Error
    By bhaskar in forum Newbie
    Replies: 1
    Last Post: 2nd June 2010, 08:24

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.