Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. HTTPS WebRequest failing with ThreadAbortException

HTTPS WebRequest failing with ThreadAbortException

Scheduled Pinned Locked Moved Visual Basic
csharpcomsalesjson
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Peter R Fletcher
    wrote on last edited by
    #1

    I am trying to download pricing data from Commonwealth Edison via their recently published Hourly Pricing API. This uses GETs from defined HTTPS URLs, and I have confirmed that typing the appropriate calls into a Web Browser results in the return of the data in the expected format. My code is as follows:

    wc = New WebClient
    strGet = "https://hourlypricing.comed.com/api?type=5minutefeed&datestart=201708040835&dateend=201708041035"
    strResult = wc.DownloadString(strGet)

    In the real Application, strGet is put together by other code, but I have checked that this is working correctly. The code here aborts with a ThreadAbortException in System.dll at the DownloadString call. If I substitute an HTTP location on one of my sites for Comed's HTTPS location in strGet, everything works as it should, and the file data is retrieved. I have researched this and tried a number of suggested 'cures' for problems with HTTPS connections under VB.NET, but the problem persists. Helpful suggestions welcomed!

    Richard DeemingR 1 Reply Last reply
    0
    • P Peter R Fletcher

      I am trying to download pricing data from Commonwealth Edison via their recently published Hourly Pricing API. This uses GETs from defined HTTPS URLs, and I have confirmed that typing the appropriate calls into a Web Browser results in the return of the data in the expected format. My code is as follows:

      wc = New WebClient
      strGet = "https://hourlypricing.comed.com/api?type=5minutefeed&datestart=201708040835&dateend=201708041035"
      strResult = wc.DownloadString(strGet)

      In the real Application, strGet is put together by other code, but I have checked that this is working correctly. The code here aborts with a ThreadAbortException in System.dll at the DownloadString call. If I substitute an HTTP location on one of my sites for Comed's HTTPS location in strGet, everything works as it should, and the file data is retrieved. I have researched this and tried a number of suggested 'cures' for problems with HTTPS connections under VB.NET, but the problem persists. Helpful suggestions welcomed!

      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #2

      I've just tried that code, and it works fine.

      [{"millisUTC":"1501860900000","price":"2.2"},{"millisUTC":"1501860600000","price":"2.2"},{"millisUTC":"1501860300000","price":"1.0"},{"millisUTC":"1501860000000","price":"0.7"},{"millisUTC":"1501859700000","price":"1.4"},{"millisUTC":"1501859400000","price":"2.1"},{"millisUTC":"1501859100000","price":"2.1"},{"millisUTC":"1501858800000","price":"2.5"},{"millisUTC":"1501858500000","price":"2.6"},{"millisUTC":"1501858200000","price":"2.6"},{"millisUTC":"1501857900000","price":"2.7"},{"millisUTC":"1501857600000","price":"2.6"},{"millisUTC":"1501857300000","price":"2.7"},{"millisUTC":"1501857000000","price":"2.7"},{"millisUTC":"1501856700000","price":"3.2"},{"millisUTC":"1501856400000","price":"2.5"},{"millisUTC":"1501856100000","price":"2.6"},{"millisUTC":"1501855800000","price":"2.9"},{"millisUTC":"1501855500000","price":"2.6"},{"millisUTC":"1501855200000","price":"2.5"},{"millisUTC":"1501854900000","price":"2.7"},{"millisUTC":"1501854600000","price":"2.5"},{"millisUTC":"1501854300000","price":"2.4"},{"millisUTC":"1501854000000","price":"2.4"},{"millisUTC":"1501853700000","price":"2.4"}]

      There must be something else going on in your application, or a problem on your network. Can you request the url from a browser running on the server? Is there a firewall in the way? Is your server configured to force an SSL v2 / v3 connection, or otherwise disabling TLS?


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      P 2 Replies Last reply
      0
      • Richard DeemingR Richard Deeming

        I've just tried that code, and it works fine.

        [{"millisUTC":"1501860900000","price":"2.2"},{"millisUTC":"1501860600000","price":"2.2"},{"millisUTC":"1501860300000","price":"1.0"},{"millisUTC":"1501860000000","price":"0.7"},{"millisUTC":"1501859700000","price":"1.4"},{"millisUTC":"1501859400000","price":"2.1"},{"millisUTC":"1501859100000","price":"2.1"},{"millisUTC":"1501858800000","price":"2.5"},{"millisUTC":"1501858500000","price":"2.6"},{"millisUTC":"1501858200000","price":"2.6"},{"millisUTC":"1501857900000","price":"2.7"},{"millisUTC":"1501857600000","price":"2.6"},{"millisUTC":"1501857300000","price":"2.7"},{"millisUTC":"1501857000000","price":"2.7"},{"millisUTC":"1501856700000","price":"3.2"},{"millisUTC":"1501856400000","price":"2.5"},{"millisUTC":"1501856100000","price":"2.6"},{"millisUTC":"1501855800000","price":"2.9"},{"millisUTC":"1501855500000","price":"2.6"},{"millisUTC":"1501855200000","price":"2.5"},{"millisUTC":"1501854900000","price":"2.7"},{"millisUTC":"1501854600000","price":"2.5"},{"millisUTC":"1501854300000","price":"2.4"},{"millisUTC":"1501854000000","price":"2.4"},{"millisUTC":"1501853700000","price":"2.4"}]

        There must be something else going on in your application, or a problem on your network. Can you request the url from a browser running on the server? Is there a firewall in the way? Is your server configured to force an SSL v2 / v3 connection, or otherwise disabling TLS?


        "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

        P Offline
        P Offline
        Peter R Fletcher
        wrote on last edited by
        #3

        My browser delivers the content of the URL without problems. I do have a regular (McAfee) firewall, but, as noted, it is not interfering with the browser accessing the same location. I have no idea how Comed's server is configured. I have a fairly standard install of Windows 10, and am having no difficulty accessing other sites, including a lot which use SSL. Running exactly the code I gave as a standalone function produced the same error on my system, but it also produced the following 'informational' message from VS: "Evaluation requires a thread to run temporarily. Use the Watch window to perform the evaluation." I wonder if this is a debugger issue. I have to drop this for now, but will return to it and report back in a couple of days when I can get back to it.

        1 Reply Last reply
        0
        • Richard DeemingR Richard Deeming

          I've just tried that code, and it works fine.

          [{"millisUTC":"1501860900000","price":"2.2"},{"millisUTC":"1501860600000","price":"2.2"},{"millisUTC":"1501860300000","price":"1.0"},{"millisUTC":"1501860000000","price":"0.7"},{"millisUTC":"1501859700000","price":"1.4"},{"millisUTC":"1501859400000","price":"2.1"},{"millisUTC":"1501859100000","price":"2.1"},{"millisUTC":"1501858800000","price":"2.5"},{"millisUTC":"1501858500000","price":"2.6"},{"millisUTC":"1501858200000","price":"2.6"},{"millisUTC":"1501857900000","price":"2.7"},{"millisUTC":"1501857600000","price":"2.6"},{"millisUTC":"1501857300000","price":"2.7"},{"millisUTC":"1501857000000","price":"2.7"},{"millisUTC":"1501856700000","price":"3.2"},{"millisUTC":"1501856400000","price":"2.5"},{"millisUTC":"1501856100000","price":"2.6"},{"millisUTC":"1501855800000","price":"2.9"},{"millisUTC":"1501855500000","price":"2.6"},{"millisUTC":"1501855200000","price":"2.5"},{"millisUTC":"1501854900000","price":"2.7"},{"millisUTC":"1501854600000","price":"2.5"},{"millisUTC":"1501854300000","price":"2.4"},{"millisUTC":"1501854000000","price":"2.4"},{"millisUTC":"1501853700000","price":"2.4"}]

          There must be something else going on in your application, or a problem on your network. Can you request the url from a browser running on the server? Is there a firewall in the way? Is your server configured to force an SSL v2 / v3 connection, or otherwise disabling TLS?


          "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

          P Offline
          P Offline
          Peter R Fletcher
          wrote on last edited by
          #4

          The problem seems to be what I can only describe as a deficiency in the Visual Studio environment - the clue was the information message described in my previous response. My usual way of testing an isolated Sub or Function while I am developing an application is either to invoke it directly from the Immediate Window, or, if this is not convenient (as it frequently isn't), to write a stub Sub which uses it and invoke that from the Immediate Window. This has always worked for me before. It appears that there is an issue with doing this to test (at least some) WebClient code, presumably because of some aspect of how code invoked from the Immediate Window is interpreted and run. If I put the code clipping from my first message in the Form_Load Function of a Windows Forms App and run the App, the code runs normally and returns the expected JSON string. If I put the identical code in a Public Sub and invoke the Sub from the VS Immediate Window, it throws the ThreadAbortException that I originally described. Perhaps the most bizarre aspect of this is the fact that the misbehavior is dependent on the URL in the request being an HTTPS one - as I noted, requests involving HTTP URLs are handled correctly, even when the code is run from the Immediate Window.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups