简体   繁体   English

Arduino 云没有得到 Azure API 的响应

[英]Arduino Yun not getting response from Azure API

I'm trying to get my Arduino Yun to talk to an API that I'm hosting on Azure.我试图让我的 Arduino Yun 与我在 Azure 上托管的 API 交谈。 I would like to do more complex things in the future, but at the moment I'm just trying to make a GET request over wifi with a single integer as a parameter.我想在未来做更复杂的事情,但目前我只是想通过 wifi 发出一个 GET 请求,使用单个 integer 作为参数。

I'm basically just using the example found here with the url changed.我基本上只是使用 此处找到的示例,其中 url 已更改。 The example works fine, so as far as I'm aware the issue isn't with my board, its with the interaction with Azure.该示例运行良好,据我所知,问题不在于我的电路板,而在于与 Azure 的交互。

HttpClient.get() returns an int as a response (not the regular HTTP response codes, its unique for the library). HttpClient.get() 返回一个 int 作为响应(不是常规的 HTTP 响应代码,它对于库来说是唯一的)。 I got 60 initially, and changing my API to accept http calls (instead of just https) fixed this and made me get a response of 0 instead.我最初得到了 60,然后将我的 API 更改为接受 http 调用(而不仅仅是 https)修复了这个问题,并让我得到了 0 的响应。 0 is the same response that I get from the working Arduino example, but for some reason I'm not actually getting anything in the body of my response, as the client.available() loop is never entered. 0 与我从工作 Arduino 示例中得到的响应相同,但由于某种原因,我的响应正文中实际上没有得到任何内容,因为从未进入 client.available() 循环。

The API works as intended when I go to the url in chrome, so the issue arises somewhere due to how the arduino and azure talk to each other, but I don't know enough about either to figure it out and nowhere that I look seems to point me in the right direction. The API works as intended when I go to the url in chrome, so the issue arises somewhere due to how the arduino and azure talk to each other, but I don't know enough about either to figure it out and nowhere that I look seems为我指明正确的方向。

Any help would be greatly appreciated, thanks.任何帮助将不胜感激,谢谢。

UPDATE更新

This question, because I don't have a development board, so I can only give you general advice.这个问题,因为我没有开发板,所以只能给你一般的建议。

Knowing the premise, there is no problem with the sample interface in the test code, and you also confirm that your azure api can be accessed through chrome normally.知道了前提,测试代码中的示例界面没有问题,同时你也确认你的azure api可以通过chrome正常访问了。

Troubleshooting steps:故障排除步骤:

  1. Modify the sample code, and print out the returned content in the sample code on the console.修改示例代码,在控制台打印出示例代码中返回的内容。

    在此处输入图像描述

Explanation: This step is to confirm whether your development board has normally instantiated HttpClient and whether it has sent http get requests normally.说明:这一步是确认你的开发板是否正常实例化了HttpClient,是否正常发送http get请求。

  1. After the first step is implemented, see if the return value obtained by the development board is still 60. At this time, modify the url and replace the request address of the azure api for testing.执行完第一步后,看开发板得到的返回值是否还是60,此时修改url,替换azure的请求地址Z8A5DA52ED126447D359E70C0572进行测试。

Suggestion: Use a simple test interface that returns string type, such as returning hello world text information, so that you can view the returned data directly on the console.建议:使用返回字符串类型的简单测试接口,比如返回hello world文本信息,这样就可以直接在控制台查看返回的数据。

  1. If the returned value is still 0, it is recommended to turn on application logs at this time and check the log of each request in the portal, so as to ensure whether the development board sends the http request to the azure web app.如果返回值仍然为0,此时建议开启应用日志,查看门户中各个请求的日志,以确保开发板是否向azure Z2567A5EC3005EB7AC89DZ948发送http请求。 The log will record the request information and results in detail.日志会详细记录请求信息和结果。 Modify the development board code according to the log.根据日志修改开发板代码。

  2. If there is no http request information in the azure logs, or the test sample code did not print the returned content at the beginning, then I guess it may be that the driver of the development board or your product has not been installed and debugged properly.如果azure日志中没有http请求信息,或者测试示例代码一开始没有打印返回的内容,那么我猜可能是开发板的驱动或者你的产品没有安装调试好. It is recommended to recheck whether the device is normal.建议重新检查设备是否正常。

PRIVIOUS私人的

Enable CORS on portal like below.在门户上Enable CORS ,如下所示。

Add * , then save it to allow all sites.添加* ,然后将其保存以允许所有站点。

在此处输入图像描述

Reason:原因:

Via screenshoot, I can see http://127.0.0.1:port want to run, and I believe if it works, it will send http request by HttpClient , so we need to enable cors first.通过截图,我可以看到http://127.0.0.1:port想要运行,我相信如果它工作,它会通过HttpClient发送 http 请求,所以我们需要先启用 ZB439A4514C277CE186FCC178。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在ubuntu x86上为arduino yun构建Azure IoT SDK - Build the Azure IoT sdk for arduino yun on ubuntu x86 从Azure Web API获得未经授权 - Getting Unauthorized from from Azure Web API Arduino API和Json向Azure发送信息 - Arduino API and Json sending information to azure 使用 Azure 数据工厂将数据从 API 复制到 Azure SQL 时,我只得到表中的第一行。 API 响应是嵌套的 JSON - While copying data from API using Azure Data Factory to Azure SQL, I'm only getting first row in table. The API response is Nested JSON Webhook 回调从 Azure Function 收到意外响应 301 - Webhook callback getting unexpected response 301 from Azure Function 502从Azure网站呼叫Google Api时无效响应 - 502 Invalid Response when calling Google Api from Azure Website Azure API 管理 - 确定响应是否来自缓存 - Azure API Management - determine if response was served from cache Azure API 策略 JSON 转换同时从缓存返回响应 - Azure API policy JSON conversion while returning the response from cache 是否可以从 azure 中的 API 请求中收集响应数据(正文)? - Is it possible to collect response data (body) from an API requests in azure? 从Azure获取C#中的XML文件作为响应 - Getting a XML file as response in C# from Azure
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM