Results 1 to 4 of 4

Thread: Timeout accessing my self hosted WCF SSL service.

  1. #1
    groadsvb is offline VB.NET Forum Enthusiast
    .NET Framework
    .NET 3.5
    Join Date
    Nov 2006
    Posts
    75
    Reputation
    130

    Timeout accessing my self hosted WCF SSL service.

    I hope that I get all the steps correct to explain what I did. In summary I created my on certificates to develop and test a self hosted WCF using SSL.
    1) i create the CA
    2) I moved that CA to the Certificates Trusted Root Authority
    3) I created a self signed certificate from the CA i created
    4) I wrote my WCF and Self hosted it.
    5) I wrote a console app and added a service reference to service in step 4 and ran the app and it worked! Cool.

    6) I wrote and new console app but did not add a service reference. I wrote my own code to call the self hosted WCF but I get a timeout. Below is the code that times out. The error is {"The operation has timed out"}.
    my x509 certificate path is to the self signed file that I exported from mmc.

    Code:
    Imports System.Net
    Imports System.IO
    Imports System.Security.Cryptography.X509Certificates
    Module Module1
    
        Sub Main()
    
            Dim webRequest As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create("http://localhost:10991/WCFCalculator")
            webRequest.Method = "POST"
            webRequest.ContentType = "text/xml; charset=utf-8"
            Dim content = "<s:Envelope xmlns:s=""http://schemas.xmlsoap.org/soap/envelope/""><s:Body><add xmlns=""http://Microsoft.ServiceModel.Samples""><a1>1</a1><a2>1</a2></add></s:Body></s:Envelope>"
            webRequest.ContentLength = content.Length
            webRequest.ClientCertificates.Add(New X509Certificate2("C:\TestData\ssl\exportedGary1.pfx", "Kangaroo", X509KeyStorageFlags.MachineKeySet))
            webRequest.Timeout = 10000
            webRequest.Headers.Add("SOAPAction", "http://Microsoft.ServiceModel.Samples/IWCFCalculator/add")
    
    
            Using sw As New StreamWriter(webRequest.GetRequestStream())
                sw.Write(content)
            End Using
    
    
            Using sr As New System.IO.StreamReader(webRequest.GetResponse().GetResponseStream)
                Dim data = sr.ReadToEnd
                Console.WriteLine(data)
                Console.Read()
            End Using
        End Sub
    
    End Module
    All help with this is greatly appreciated.
    GAR

  2. #2
    JohnH's Avatar
    JohnH is offline VB.NET Forum Moderator
    .NET Framework
    .NET 4.5
    Join Date
    Dec 2005
    Location
    Norway
    Posts
    15,087
    Reputation
    2803
    The ssl service url must be https at least, not http. Why would you not use the client proxy?
    How to format posts with code blocks etc - present the problem/post properly

    Visual Studio Community 2017

  3. #3
    groadsvb is offline VB.NET Forum Enthusiast
    .NET Framework
    .NET 3.5
    Join Date
    Nov 2006
    Posts
    75
    Reputation
    130
    I did see that I copy over the code when I had it as non ssl. I have https in the running version that gave me the time out. I just got it to run with out the timeout but I am not sure why this makes a difference yet. If anyone has input, welcome all. To get it to work I changed the storage flags from MachineKeySet to UserKeySet and I no longer time out.
    GAR

  4. #4
    groadsvb is offline VB.NET Forum Enthusiast
    .NET Framework
    .NET 3.5
    Join Date
    Nov 2006
    Posts
    75
    Reputation
    130
    Hi JohnH:
    Thanks for the reply. I do not completely understand all about the request and hosting so I may not understand completely the client proxy concept. To finish the task that I have been assigned I don't know if I have that option. Or is a client proxy always an option when writing this type of exchange?
    GAR

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
  •