问题描述
最近使用vscode配sftp同步项目文件的时候,发现连到组里的服务器handshake时间大约需要20s左右,而vscode中sftp插件的默认配置和插件config wiki中并没有最大超时时间的设置参数(其实是有的)
//默认config -- sftp.json
{
"name": "My Server",
"host": "localhost",
"protocol": "sftp",
"port": 22,
"username": "username",
"remotePath": "/",
"uploadOnSave": true
}
解决方案
先说解决方案:通过插件的debug模式,在控制台中,有如下log:
[info] config at f:\****** {"remotePath":"******","uploadOnSave":true,"downloadOnOpen":false,"ignore":[],"concurrency":4,"protocol":"sftp","connectTimeout":10000,"interactiveAuth":false,"secure":false,"remoteTimeOffsetInHours":0,"name":"My Server","host":"******","port":22,"username":"******","password":"******"}
可以看到连接配置中是存在最大超时时间 —— connectTimeout这一参数的。
所以,只需要更改connectTimeout的值即可完成最大超时时间的配置,如下:
{
"name": "My Server",
//...
//配置最大超时时间
"connectTimeout":100000
}
现已将该情况以issue的形式反映给插件作者
很推荐这个插件,特别是在修改实验代码的时候,使用也非常简单,如果仅是利用sftp的话,只需配置主机ip和登陆用户即可(类比于console下的sftp xxxx@xx.xx.xx.xx
)