14

I am trying to create a service bus relay based on this article

I get an error message Generic: InvalidSignature: The token has an invalid signature.

static void Main(string[] args)
{
        ServiceHost sh = new ServiceHost(typeof(ProblemSolver));

        sh.AddServiceEndpoint(
           typeof(IProblemSolver), new NetTcpBinding(),
           "net.tcp://tjservicebus.servicebus.windows.net/solver");

        Console.WriteLine("Add Binding End Point");

        var key = "MYKEY";

        sh.AddServiceEndpoint(
           typeof(IProblemSolver), new NetTcpRelayBinding(),
           ServiceBusEnvironment.CreateServiceUri("sb", "tjservicebus", "solver"))
            .Behaviors.Add(new TransportClientEndpointBehavior
            {
                TokenProvider = TokenProvider.CreateSharedAccessSignatureTokenProvider("RootManageSharedAccessKey", key)
            });

        sh.Open();

        Console.WriteLine("Press ENTER to close");
        Console.ReadLine();

        sh.Close();
    }

The error message appears at the point of sh.Open();

Can anyone help?

Frazer
  • 560
  • 2
  • 11
  • 21

4 Answers4

7

I also had this error message and it turned out to be the same issue as Andy Zhang.

I deleted the service bus to test automated deployment and was still referencing the old SharedAccessKey in the connection string to connect but this had changed after redeployment.

We stored our connection string in Key Vault, so I had to change the connection string in there to resolve the issue.

Dave C
  • 457
  • 3
  • 10
3

I encountered the same error as your first.

But my problem is I used the connection string as the key. Then I have changed the last parameter SharedAccessKey for the key, and the error has been resolved.

Racil Hilan
  • 24,690
  • 13
  • 50
  • 55
Andy Zhang
  • 39
  • 2
0

Specifically for me within my local environment, I had made changes to environment variables -- one of which was a service bus connection string -- while Visual Studio was open.

Visual Studio will cache environment variables on start up.

Closing Visual Studio, re-opening and running again solved my issue.

madebybear
  • 359
  • 4
  • 8
-6

Looks like I have sorted the problem, a forward slash in the key was not escaped

The next problem is im now getting the following but want to rule out our firewall first

<Error>
  <Code>400</Code>
    <Detail>
      Cannot send message because the service endpoint hosted at the specified address uses a binding that cannot be accessed over HTTP. TrackingId:7e6402e1-a250-482b-967e-a4d1860bca54_G37,TimeStamp:11/12/2015 9:09:15 AM
    </Detail>
</Error>
Frazer
  • 560
  • 2
  • 11
  • 21