UWP 树莓派网络服务器问题 [英] UWP Raspberry Pi Webserver issue

查看:38
本文介绍了UWP 树莓派网络服务器问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在关注 Web 服务器的示例应用程序,通过带有端口的 TCP 处理传入请求.

I'm following the sample application of a Webserver, handling incoming requests through TCP with a Port.

带有代码的示例应用程序:https://incredibits.io/project/windows-10-iot-internet-of-things-tips/windows-10-iot-raspberry-pi-web-server

Sample application with code: https://incredibits.io/project/windows-10-iot-internet-of-things-tips/windows-10-iot-raspberry-pi-web-server

在我的 Windows 10 机器上调试 UWP 应用程序并尝试访问本地 IP(192.168.x.x <-当然我已经输入了我的实际本地 IP)时,我得到了我应该得到的.应用程序获取传入请求并将一些数据返回给我另一台计算机上的我(客户端).

When debugging the UWP application on my Windows 10 machine, and try to access the the local IP (192.168.x.x <- Ofcourse I've entered my actual local IP) I get what I'm supposed to. The application get's an incoming request and returns some data back to me (The client) on another computer of mine.

我面临的问题是,当我将它部署到运行 Windows 10 IoT Core(来自 Insider 的最新版本)的 Raspberry Pi 3 时,我根本无法从我的客户端计算机访问该应用程序.这是 Pi 的防火墙的问题还是其他什么阻止了这种情况?

The issues I'm facing is when I deploy this to my Raspberry Pi 3 running Windows 10 IoT Core (The newest from Insider), I can't access the application from my client computer at all. Is this a thing with the Pi's firewall or something else preventing this?

我可以在端口 8080 上访问 IoT Core 的 Web 界面,但是我无法访问在端口 80 上运行的应用程序.(我也尝试将端口切换到另一个端口,在我的 Windows 10 上本地运行,但在 Pi 上不起作用)

I CAN access the IoT Core's Web interface on port 8080, but I cannot access my application running on port 80. (I've tried switching the port to another one aswell, works locally on my Windows 10 but not on the Pi)

有没有人知道解决方案,或者遇到过类似的问题?

Does anyone know a solution, or have faced a similar issue?

注意:我也试过这样的例子 (https://ms-iot.github.io/content/en-US/win10/samples/BlinkyWebServer.htm),同样适用于我的 Windows 10 电脑,如果我的另一台电脑在同一网络上,则可以被我的其他电脑访问,但不能在我的 Pi 上访问)

Note: I've also tried examples like (https://ms-iot.github.io/content/en-US/win10/samples/BlinkyWebServer.htm) which again, works on my Windows 10 pc, and can be accessed by my other PC if their on the same network, but not on my Pi)

推荐答案

我找到了问题的解决方案.

I found the solution to my problem.

我使用的端口没有在 Raspberry Pi 的防火墙中打开.我找不到如何向防火墙添加规则,但在 Freenode C# 聊天论坛上获得一些帮助后,我发现了以下代码段:

The port I was using, wasn't opened up in the Raspberry Pi's Firewall. I couldn't find how to add a rule to the Firewall but after some help on Freenode C# Chat forum, I found the following snippet:

首先我通过 PowerShell 登录 Pi

First I log into the Pi through PowerShell

Enter-PsSession -ComputerName MyRaspberryPi-Credential MyRaspberryPiAdministrator

然后我手动添加我正在使用的端口的防火墙开放.在本例中为 8080 端口.

Then I manually add the Firewall opening of the port I'm using. In this case port 8080.

netsh advfirewall firewall add rule name="Raspberry Pi Webserver" dir=in action=allow protocol=TCP localport=8080

在那之后,一切都按预期进行.我可以访问我的 Raspberry Pi 上的端口!一切顺利!

After that, everything worked as expected. I could access the port on my Raspberry Pi! All good!

感谢@canton7 和@taylor-kidd 在评论中提出的建议最终帮助了我!

Thanks to @canton7 and @taylor-kidd in the comments, for coming with suggestions that in the end helped me!

编辑 4 月 12 日:这个防火墙没有打开的问题似乎已经是微软的一个已知问题.他们在他们的 Insider Preview 版本 14295(我正在使用的版本)的发布说明中写到了这一点 http://ms-iot.github.io/content/en-US/win10/ReleaseNotesInsiderPreview.htm

EDIT 12th of April: It seems like this issue with the Firewall not being opened, was actually a known issue by Microsoft already. They write that in their Relase notes for the Insider Preview version 14295 (Which I am using) here http://ms-iot.github.io/content/en-US/win10/ReleaseNotesInsiderPreview.htm

这篇关于UWP 树莓派网络服务器问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆