[英]API Gateway Websocket @Connection endpoint not found
我試圖從$ 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網關URL匹配。
Visual Studio 2017
.Net Core 2.1
AWSSDK.ApiGatewayManagementApi 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使用任何類型的緩存系統可能會鎖定到舊版本。 它現在正在工作。 很抱歉延遲發布我的調查結果!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.