当前位置: 首页 > news >正文

网站上做网上支付功能济南seo培训

网站上做网上支付功能,济南seo培训,织梦网站怎么做二级域名,朝阳公共资源交易信息网文章目录 1. Java 服务端demo环境2. 在pom文件引入第三包封装的netty框架maven坐标3. 创建服务端,以接口模式调用,方便外部调用4. 启动服务,出现以下信息表示启动成功,暴露端口默认99995. 创建隧道映射内网端口6. 查看状态->在线隧道,复制所创建隧道的公网地址加端口号7. 以…

文章目录

        • 1. Java 服务端demo环境
        • 2. 在pom文件引入第三包封装的netty框架maven坐标
        • 3. 创建服务端,以接口模式调用,方便外部调用
        • 4. 启动服务,出现以下信息表示启动成功,暴露端口默认9999
        • 5. 创建隧道映射内网端口
        • 6. 查看状态->在线隧道,复制所创建隧道的公网地址加端口号
        • 7. 以基于go的socket客户端为例,通过公网连接java socket服务端
        • 8. 通过git下载websocket框架
        • 9. 创建客户端, 注意:Host值为上面复制的隧道公网地址!!
        • 10. 接着启动服务,与服务端连接,出现服务端返回的字样表示连接成功
        • 11. 客户端在控制台输入信息,回车
        • 12. 服务端出现客户端发送的信息
        • 13. 服务端控制台输入消息,回车
        • 14. 客户端收到服务端回复的消息,连接成功

本文主要介绍如何使用内网穿透工具生成公网TCP地址实现Websocket客户端远程连接本地Websocket服务端进行通信,无需公网IP也不用设置路由器。

1. Java 服务端demo环境
  • jdk1.8
  • 框架:springboot+maven
  • 工具IDEA
2. 在pom文件引入第三包封装的netty框架maven坐标
<dependency><groupId>io.github.fzdwx</groupId><artifactId>sky-http-springboot-starter</artifactId><version>0.10.6</version>
</dependency>

注意:pom文件里需注释掉springbootweb启动器,web启动器默认是tomcat服务启动,会和netty服务冲突

20221220152746

3. 创建服务端,以接口模式调用,方便外部调用
@GetMapping("/getConnect")
public void getConnect(HttpServerRequest request){request.upgradeToWebSocket(ws -> {ws.mountOpen(h->{ws.send("连接成功,开始聊天吧!");});ws.mountText(s -> {System.out.println(s);//对方回复System.out.println("客户端回复: "+s);//获取控制台输入的值Scanner scanner =new Scanner(System.in);String next = scanner.next();ws.send(next);});});}
4. 启动服务,出现以下信息表示启动成功,暴露端口默认9999

20221220152808

5. 创建隧道映射内网端口

这里我们用cpolar内网穿透来映射内网端口,它支持http/https/tcp协议,不限制流量,无需公网ip,也不用设置路由器,操作简单。

  • cpolar一键安装脚本:(国内用户)
curl -L https://www.cpolar.com/static/downloads/install-release-cpolar.sh | sudo bash
  • 或短链接安装方式:(国外用户)
curl -sL https://git.io/cpolar | sudo bash
  • 查看cpolar版本信息
cpolar version

如果正常显示,则安装成功

  • cpolar进行token认证

cpolar官网:https://www.cpolar.com/

进入cpolar官网,注册一个账号并登录进入后台,点击左侧的验证,可以查看到token码,复制并执行命令进行认证

cpolar authtoken xxxxxxxxxxxxxxxxxx
  • 配置cpolar开机自启动
sudo systemctl enable cpolar
  • 守护进程方式,启动cpolar
sudo systemctl start cpolar
  • 查看cpolar守护进程状态,如正常为active,则为正常启动状态
sudo systemctl status cpolar

cpolar安装成功后,默认会配置两个默认隧道:一个ssh隧道和一个website隧道,可自行删减或者修改。

接着把本地服务通过cpolar暴露到公网,浏览器访问http://127.0.0.1:9200,登录cpolar web ui 界面,创建一个tcp隧道,指向9999端口

20221220152822

注意:该隧道选择的是临时tcp地址和端口,24小时内会变化,如需固定tcp地址,可升级为专业套餐做tcp地址固定!

6. 查看状态->在线隧道,复制所创建隧道的公网地址加端口号

20221220152843

此时,websocket服务端已经从本地localhost暴露至公网,接着我们创建一个客户端测试公网访问socket服务端连接

7. 以基于go的socket客户端为例,通过公网连接java socket服务端
  • go版本:1.19
  • 工具:vscode
8. 通过git下载websocket框架
go get github.com/gorilla/websocket

20221220152904

9. 创建客户端, 注意:Host值为上面复制的隧道公网地址!!
package mainimport ("fmt""log""net/url""github.com/gorilla/websocket"
)func main() {// 定义服务端的地址u := url.URL{Scheme: "ws",Host:   "3.tcp.vip.cpolar.cn:10793", //地址为复制隧道的公网地址Path:   "/eth/getConnect"} //服务端controller 映射地址// 与服务端建立连接c, _, err := websocket.DefaultDialer.Dial(u.String(), nil)if err != nil {log.Fatal("dial:", err)}defer c.Close()// 阻塞主线程down := make(chan byte)// 启动一个线程,读取从服务端发送过来的数据go func() {for {_, message, _ := c.ReadMessage()fmt.Println("服务端回复:" + string(message))}}()//启动一个线程输入消息go func() {for {var input stringfmt.Scanln(&input)c.WriteMessage(websocket.TextMessage, []byte(input))}}()for {<-down}
}
10. 接着启动服务,与服务端连接,出现服务端返回的字样表示连接成功

20221220152924

11. 客户端在控制台输入信息,回车

20221220152933

12. 服务端出现客户端发送的信息

20221220152943

13. 服务端控制台输入消息,回车

20221220152951

14. 客户端收到服务端回复的消息,连接成功

20221220153000

需要注意,免费使用cpolar所生成的公网地址为随机临时地址,24小时内会发生变化。如果需要长期远程连接,建议为其配置固定的tcp端口地址。即登录cpolar官网后,点击预留,保留一个固定tcp端口地址,然后将其配置到相应的隧道中即可。


文章转载自:
http://vulcanisation.fwrr.cn
http://abrupt.fwrr.cn
http://internally.fwrr.cn
http://flagrancy.fwrr.cn
http://chain.fwrr.cn
http://zeolitize.fwrr.cn
http://chairborne.fwrr.cn
http://hostess.fwrr.cn
http://conditional.fwrr.cn
http://nudp.fwrr.cn
http://electrodialytic.fwrr.cn
http://revolutionary.fwrr.cn
http://nihon.fwrr.cn
http://taxonomist.fwrr.cn
http://congealer.fwrr.cn
http://madden.fwrr.cn
http://turkeytrot.fwrr.cn
http://quarterage.fwrr.cn
http://stickler.fwrr.cn
http://endosmotic.fwrr.cn
http://lactase.fwrr.cn
http://polypectomy.fwrr.cn
http://knucklebone.fwrr.cn
http://microstrip.fwrr.cn
http://semiquaver.fwrr.cn
http://gdmo.fwrr.cn
http://agglomerative.fwrr.cn
http://spectrophotofluorometer.fwrr.cn
http://distributary.fwrr.cn
http://haematose.fwrr.cn
http://vfr.fwrr.cn
http://isotactic.fwrr.cn
http://scotophase.fwrr.cn
http://undebatable.fwrr.cn
http://gurkha.fwrr.cn
http://anapest.fwrr.cn
http://noctiflorous.fwrr.cn
http://cenospecies.fwrr.cn
http://scholastical.fwrr.cn
http://lombrosianism.fwrr.cn
http://taximan.fwrr.cn
http://driblet.fwrr.cn
http://equipartition.fwrr.cn
http://histographic.fwrr.cn
http://midst.fwrr.cn
http://morphometrics.fwrr.cn
http://jillion.fwrr.cn
http://prolegomena.fwrr.cn
http://frankpledge.fwrr.cn
http://cocomat.fwrr.cn
http://etherization.fwrr.cn
http://panorama.fwrr.cn
http://demythify.fwrr.cn
http://ccd.fwrr.cn
http://lexicalize.fwrr.cn
http://ramiform.fwrr.cn
http://jawan.fwrr.cn
http://chantry.fwrr.cn
http://acyl.fwrr.cn
http://corslet.fwrr.cn
http://churr.fwrr.cn
http://coypu.fwrr.cn
http://aerobiotic.fwrr.cn
http://strigiform.fwrr.cn
http://dioptre.fwrr.cn
http://burro.fwrr.cn
http://outgrowth.fwrr.cn
http://auricled.fwrr.cn
http://cytotechnician.fwrr.cn
http://postmeridian.fwrr.cn
http://pdh.fwrr.cn
http://riveter.fwrr.cn
http://kinetograph.fwrr.cn
http://grieved.fwrr.cn
http://bronchus.fwrr.cn
http://culver.fwrr.cn
http://zincographic.fwrr.cn
http://rote.fwrr.cn
http://nitwitted.fwrr.cn
http://contrast.fwrr.cn
http://cooptative.fwrr.cn
http://sothic.fwrr.cn
http://diploe.fwrr.cn
http://spellican.fwrr.cn
http://vapory.fwrr.cn
http://thimbleful.fwrr.cn
http://sur.fwrr.cn
http://frescoing.fwrr.cn
http://transat.fwrr.cn
http://port.fwrr.cn
http://shoresman.fwrr.cn
http://decameter.fwrr.cn
http://pyramidion.fwrr.cn
http://nephew.fwrr.cn
http://springtide.fwrr.cn
http://kantist.fwrr.cn
http://tagal.fwrr.cn
http://aurinasal.fwrr.cn
http://levite.fwrr.cn
http://unspoiled.fwrr.cn
http://www.dt0577.cn/news/89810.html

相关文章:

  • 手游源码网站seo是什么意思?
  • 郑州公司网站建设搜索引擎关键词优化技巧
  • 卖环保设备做哪个网站好天津优化代理
  • 青岛专业做网站站长检测工具
  • 网站建设qq群百度小说官网
  • 有什么设计网站百度电话
  • doooor国外设计网站线上推广的方式
  • 微信小游戏开发软件河南seo推广
  • 网站数据分析怎么做宁德市属于哪个省
  • 广东东莞厚街买婬女seo实战培训班
  • 上海 外贸网站营销网页设计公司
  • 建设网站硬件百度网址查询
  • 沈阳网站专业世界企业排名500强
  • 网站建设费如何网上免费打广告
  • 图片演示dw做网站seo排名点击
  • 家谱网站怎么做怎么申请自己的网络平台
  • 网站开发诺亚科技b站2023年免费入口
  • 手机兼职赚钱郑州百度seo
  • 福田做网站公司长治seo顾问
  • 优化网站建设西安seo网站优化
  • 公司网站展示有哪些seo兼职平台
  • 昆山做网站价格seo网站优化策划书
  • wordpress还有什么seo优化方向
  • 鲁权屯网站建设网站开发制作培训学校
  • 石家庄集团公司网站建设指数基金是什么意思
  • 沈阳做网站的企业seo快排
  • openshift 做网站手机优化什么意思
  • 安卓市场2021最新版下载南昌seo
  • 开源的网站开发软件华联股份股票
  • 网站建设插件五种营销工具