我正在尝试从 $connect 路由向潜在连接的客户端发送套接字消息。我成功地从 dynamodb 检索到连接 ID。每当我尝试发送任何东西时,都会收到错误消息:
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 Gateway url 匹配。
视觉工作室 2017
.Net 核心 2.1
AWSSDK.ApiGatewayManagementApi 3.3.100.23
谢谢!