2016-01-28 54 views
0

我试图配置我的谷歌云实例,以允许外部流量,所以我可以设置一个Web套接字;尽管为所有外部TCP/IP流量添加了规则,但我无法访问它。我的规则是:gcloud compute:为外部流量配置防火墙

gcloud compute firewall-rules list 
NAME    NETWORK SRC_RANGES RULES SRC_TAGS TARGET_TAGS 
default-allow-ssh default 0.0.0.0/0 tcp:22 
external-traffic default 0.0.0.0/0 tcp,udp 


gcloud compute instances list 
NAME  ZONE   MACHINE_TYPE PREEMPTIBLE INTERNAL_IP EXTERNAL_IP STATUS 
pi-server us-central1-a n1-standard-1    **.***.*.* **.***.***.*** RUNNING 

我已经完成了这个静态IP(这显示在我的云仪表板):

Name    External Address Region  Type In use by 
crypto-iris-****** **.***.***.*** us-central1 Static VM instance my_instance_name (Zone a) 

我也有一些转到客户机/服务器网络套接字代码完美的作品在我的电脑上使用localhost:8080作为地址。所以,我的问题是:我可以简单地用这些规则下的实例的外部静态IP替换localhost吗?

我的客户利用的"github.com/gorilla/websocket"在客户端的8080端口输出本地为:根据要求

connecting to ws://23.251.148.133:8080/echo 
dial:dial tcp 23.251.148.133:8080: getsockopt: operation timed out 
exit status 1 

代码,如果任何人希望看到它。

+0

您是如何创建“外部流量”防火墙规则的?我想你可能不得不通过一个特定的端口。 对于端口8080上的websocket,这可能有效: gcloud compute防火墙规则创建websocket --allow tcp:8080 – dlorenc

回答