C# 未找到API网关Websocket@连接终结点
我正试图从$connect路由向可能连接的客户端发送套接字消息。我成功地从dynamodb检索到连接id。每当我尝试发送任何内容时,都会出现以下错误:C# 未找到API网关Websocket@连接终结点,c#,.net,aws-sdk-net,C#,.net,Aws Sdk Net,我正试图从$connect路由向可能连接的客户端发送套接字消息。我成功地从dynamodb检索到连接id。每当我尝试发送任何内容时,都会出现以下错误: No method found matching route %40connections/aM50DdTXCYcCGEA%3D for http method POST 我用来发送的代码: Amazon.Runtime.AWSCredentials cd = new Amazon.Runtime.BasicAWSCredentials("**
No method found matching route %40connections/aM50DdTXCYcCGEA%3D for http method POST
我用来发送的代码:
Amazon.Runtime.AWSCredentials cd = new Amazon.Runtime.BasicAWSCredentials("*******", "******");
var domainName = request.RequestContext.DomainName;
var endpoint = $"https://{domainName}/{stage}";
context.Logger.LogLine($"API Gateway management endpoint: {endpoint}");
apiClient = new AmazonApiGatewayManagementApiClient(cd,
new AmazonApiGatewayManagementApiConfig
{
ServiceURL = endpoint,
RegionEndpoint = Amazon.RegionEndpoint.USEast2
});
Message testMessage = new Message()
{
AppId = "TestApp",
CommandData = "Testing"
};
MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(testMessage)));
PostToConnectionResponse response = await apiClient.PostToConnectionAsync(new PostToConnectionRequest()
{
ConnectionId = Uri.EscapeUriString(existing.ConnectionId),
Data = stream
});
我似乎找不到任何东西可以说明POST的端点为什么不工作(我在nodejs中有一个工作示例,但我们需要在.Net中完成)。如果有人对我如何找到问题所在有任何建议,我将不胜感激
我已经确认端点与部署的WebSocket API网关url匹配
Visual Studio 2017
.Net核心2.1
AWSSDK.API网关管理API 3.3.100.23
谢谢 我用相同的代码做了更多更少的工作,而且效果很好
AmazonApiGatewayManagementApiClient client = new AmazonApiGatewayManagementApiClient(new AmazonApiGatewayManagementApiConfig() {
ServiceURL = "https://" + request.RequestContext.DomainName + "/" + request.RequestContext.Stage
});
MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(document)));
PostToConnectionRequest postRequest = new PostToConnectionRequest()
{
ConnectionId = request.RequestContext.ConnectionId,
Data = stream
};
var result = client.PostToConnectionAsync(postRequest);
result.Wait();
我最终删除了所有IAM角色并重新创建了它们。我猜有些东西配置错误,或者如果IAM使用任何类型的缓存系统,可能会锁定到旧版本。不过它现在起作用了。很抱歉延迟在这里发布我的发现 你的答案只提供了代码以外的信息。详细说明为什么要做事情