Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I/O Timeout Error #53

Closed
emiryumak opened this issue May 16, 2020 · 25 comments
Closed

I/O Timeout Error #53

emiryumak opened this issue May 16, 2020 · 25 comments

Comments

@emiryumak
Copy link

emiryumak commented May 16, 2020

It doesn't just make any other error:

`======CMD======
docker rm -f $(docker ps -aq -f name=erp-front)
docker rmi $(docker images | grep 'emiryumak/erp-front' | awk '{print $3}')
docker pull emiryumak/erp-front:latest
docker run --name erp-front -p 5000:80 --restart=always -d emiryumak/erp-front

======END======
======ENV======

======END======
2020/05/16 20:31:15 dial tcp :: i/o timeout`

I don't understand thats error. Its meaning can not connect to my server?

@appleboy
Copy link
Owner

Please post your config and help to try the latest version?

@emiryumak
Copy link
Author

emiryumak commented Jun 18, 2020

Please post your config and help to try the latest version?

Hi thank you for your reply

my workflow file;

name: KantERP APP Container
on:
push:
branches:
- master
jobs:
build:
....
release:
needs: build
runs-on: ubuntu-latest
steps:
- name: executing remote ssh commands using password
uses: appleboy/ssh-action@v0.1.2
with:
host: ${{ secrets.KANT_SSH_HOST }}
username: ${{ secrets.KANT_SSH_USERNAME }}
password: ${{ secrets.KANT_SSH_PASSWORD }}
port: ${{ secrets.KANT_SSH_PORT }}
debug: true
script: |
docker rm -f erp-app
docker rmi kantist/erp-app
docker login --username ${{ secrets.DOCKER_USERNAME }} --password ${{ secrets.DOCKER_PASSWORD }}
docker pull kantist/erp-app:latest
docker run --name erp-app -p 9101:80 --restart=always -d kantist/erp-app

its return
/usr/bin/docker run --name d33c8fb8f67113483d82f46f8df194eda4_5f5a1e --label 3888d3 --workdir /github/workspace --rm -e INPUT_HOST -e INPUT_USERNAME -e INPUT_PASSWORD -e INPUT_PORT -e INPUT_DEBUG -e INPUT_SCRIPT -e INPUT_PASSPHRASE -e INPUT_SYNC -e INPUT_USE_INSECURE_CIPHER -e INPUT_CIPHER -e INPUT_TIMEOUT -e INPUT_COMMAND_TIMEOUT -e INPUT_KEY -e INPUT_KEY_PATH -e INPUT_FINGERPRINT -e INPUT_PROXY_HOST -e INPUT_PROXY_PORT -e INPUT_PROXY_USERNAME -e INPUT_PROXY_PASSWORD -e INPUT_PROXY_PASSPHRASE -e INPUT_PROXY_TIMEOUT -e INPUT_PROXY_KEY -e INPUT_PROXY_KEY_PATH -e INPUT_PROXY_FINGERPRINT -e INPUT_PROXY_CIPHER -e INPUT_PROXY_USE_INSECURE_CIPHER -e INPUT_SCRIPT_STOP -e INPUT_ENVS -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/erp-app/erp-app":"/github/workspace" 3888d3:3c8fb8f67113483d82f46f8df194eda4
======CMD======
docker rm -f erp-app
docker rmi ***/erp-app
docker login --username *** --password ***
docker pull ***/erp-app:latest
docker run --name erp-app -p 9101:80 --restart=always -d ***/erp-app

======END======
======ENV======

======END======
2020/06/18 10:06:57 dial tcp :: i/o timeout

I tried to upgrade the timeout not working thats.

@appleboy
Copy link
Owner

Can you make sure that you can ssh to the remote server using the following config?

host: ${{ secrets.KANT_SSH_HOST }}
username: ${{ secrets.KANT_SSH_USERNAME }}
password: ${{ secrets.KANT_SSH_PASSWORD }}
port: ${{ secrets.KANT_SSH_PORT }}

@emiryumak
Copy link
Author

Can you make sure that you can ssh to the remote server using the following config?

host: ${{ secrets.KANT_SSH_HOST }}

username: ${{ secrets.KANT_SSH_USERNAME }}

password: ${{ secrets.KANT_SSH_PASSWORD }}

port: ${{ secrets.KANT_SSH_PORT }}

It’s working on my macbook air terminal

@appleboy
Copy link
Owner

@emiryumak I will add some debug information in the plugin.

@emiryumak
Copy link
Author

Hi @appleboy i test this for @master branch your plugin. I can not see another debug information. Thats all log;

docker rm -f erp-app
docker rmi ***/erp-app
docker login --username *** --password ***
docker pull ***/erp-app:latest
docker run --name erp-app -p 9101:80 --restart=always -d ***/erp-app

======END======
======ENV======

======END======
2020/06/27 11:20:50 dial tcp ***:***: connect: connection timed out

@hopewise
Copy link

hopewise commented Aug 5, 2020

I am having the same issue, although it has to work before.. I can ssh using my mac with the same private key, user and port

@chaudharykiran
Copy link

chaudharykiran commented Aug 19, 2020

I have same issue as well.

@appleboy
Copy link
Owner

duplicated of #32

@brerdem
Copy link

brerdem commented Sep 7, 2020

I'm getting the same error. Trying to connect to a Windows Server 2008 r2 with freesshd on it.

@gokdeemir
Copy link

I have this same error, Although I checked my secrets three times.

@paul-uz
Copy link

paul-uz commented Nov 16, 2020

Same error here, using fully valid SSH credentials (username, host + secret key)

@zhuhanming
Copy link

I faced the same issue as well (while having none with appleboy/scp-action) and was eventually able to resolve this by reconfiguring ufw on my server. The action for 22/tcp was LIMIT for some reason.

Running

sudo ufw allow ssh

fixed it for me.

@Shaance
Copy link

Shaance commented Feb 17, 2021

I faced the same issue as well (while having none with appleboy/scp-action) and was eventually able to resolve this by reconfiguring ufw on my server. The action for 22/tcp was LIMIT for some reason.

Running

sudo ufw allow ssh

fixed it for me.

Using GCP where I have ssh allowed on instance firewall and executed sudo ufw allow ssh, checked it was enabled with sudo ufw status and it is. Still facing timeout issue.

@danieeis
Copy link

I had the same issue, occurs sometimes, no always. But is frustacting. I check my secrets and is correct, the ufw allow ssh is set. So.. is an issue intermittent. When re run all jobs fix the problem, but sometimes no.

@ghost
Copy link

ghost commented Nov 9, 2021

This fixed my issue,
Add IP addresses of "actions" from https://api.github.com/meta to server your ssh'ing into.
Github server ips change so if starts failing again they need to change

@luisfalconmx
Copy link

The Problem

After several hours trying to solve this problem, I came to the next conclusion:

Apparently there are some commands like docker rm -f $(docker ps -aq -f name=erp-front) or docker rmi $(docker images | grep 'emiryumak/erp-front' | awk '{print $3}') that make the connection saturate and throw the I/O Timeout error.

This may be because the command docker rmi $(docker images | grep 'emiryumak/erp-front' | awk '{print $3}') first tries to return all images named emiryumak/erp-front and then remove each of them, which can be too complicated to process.

Possible Solution

My recommendation would be to keep the commands as simple as possible or use them as shown in official documentation. Also make sure you configure the credentials correctly. In case you use an ssh key make sure to add the public key on the server and the private key in the repository as a secret.

Setting up a SSH Key

Some examples of how to use the commands correctly.

Delete a specific container

# ❌ do not this
docker rm -f $(docker ps -aq -f name=erp-front)
# ✅ do this
docker rm my_super_app -f

# or this
docker run --name my_super_app -d --rm -p 80:80 octocat/myimage:latest
docker stop my_super_app

Delete old and unused images

# ❌ do not this
docker rmi $(docker images | grep 'emiryumak/erp-front' | awk '{print $3}')
# ✅ do this
docker image prune -a -f

Workflow File

This is the configuration that I am using to run a docker container on a server via ssh every time I publish a new release

name: CD
on:
  release:
    types: [published]
jobs:
  deploy:
    name: Deploy
    runs-on: ubuntu-latest
    steps:
      - name: Deploy to server
        uses: appleboy/ssh-action@master
        with:
          host: ${{ secrets.SSH_HOST }}
          username: ${{ secrets.SSH_USER }}
          key: ${{ secrets.SSH_KEY }}
          port: ${{ secrets.SSH_PORT }}
          script: |
            docker system prune -a -f
            docker stop my_super_app
            docker run --name my_super_app -d --rm -p 80:80 octocat/myimage:latest

With environment variables

name: CD
on:
  release:
    types: [published]
jobs:
  deploy:
    name: Deploy
    runs-on: ubuntu-latest
    steps:
      - name: Get repository metadata
        uses: varunsridharan/action-repository-meta@main
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      - name: Deploy to server
        uses: appleboy/ssh-action@master
        with:
          host: ${{ secrets.SSH_HOST }}
          username: ${{ secrets.SSH_USER }}
          key: ${{ secrets.SSH_KEY }}
          port: ${{ secrets.SSH_PORT }}
          script: |
            docker system prune -a -f
            docker stop ${{ env.REPOSITORY_OWNER }}_${{ env.REPOSITORY_SLUG }}
            docker run --name ${{ env.REPOSITORY_OWNER }}_${{ env.REPOSITORY_SLUG }} -d --rm -p ${{ secrets.APP_PORT }} ${{ env.REPOSITORY_FULL_NAME }}:latest

I hope this information has been useful to you 😉

@emiryumak
Copy link
Author

I tried to connect with key, not password. And I added the private key to authorized_keys in /root/.ssh. Finally it worked :)

@tlhunter
Copy link

tlhunter commented Feb 26, 2022

I just started getting this issue as well. The commands I was executing on the remote server was a series of docker commands as part of my deployment process. I connected to the server and ran them manually and they ran fine.

@luisfalconmx's comment stood out to me since I was also running docker commands. I connected to a box and ran docker image prune -a -f it took a minute but then completed, clearing up 8GB of space on the machine. After that the deployment actions using SSH completed successfully.

I suspect the machine may have slowed down due to all the images on disk. I'm going to try incorporating docker image prune -a -f into my deployment process and see if it helps with future deployments. Certainly all that space consumption will eventually strangle the server anyway.

@bhaumikdhebar
Copy link

I was facing the same issue and I have solved it..
I have first used @Shaance's way then I have changed inbound and outbound for EC-2 instance ( Security Groups).
Some other debugging and bingo it works now... Thanks to all

@GarryOne
Copy link

In my case, it was a conflict because I was declaring to use it for the Node app, while this was affecting the ssh-action.

env:
  PORT: 8000

The solution was to rename the variable from PORT to APP_PORT.

@agustinustheo
Copy link

In my case, it was a conflict because I was declaring to use it for the Node app, while this was affecting the ssh-action.

env:
  PORT: 8000

The solution was to rename the variable from PORT to APP_PORT.

Thank you for this, it helped me.

@paulohliima
Copy link

guys, i resolved my problem switch version uses: appleboy/ssh-action@master to appleboy/ssh-action@v.0.1.3 and waiting deploy action, after switch again to appleboy/ssh-action@master and run e enjoy. When changing to the version 0.1.3 action, it will give an error, but after going back to master, it will work. Resolved with me.

@appleboy
Copy link
Owner

I will remove the unused global variable on drone-ssh. Thanks for all feedback.

appleboy added a commit to appleboy/drone-ssh that referenced this issue Apr 13, 2023
- Modify the `EnvVars` slice to include `INPUT_` prefix when needed
- Remove unused environment variables from the `EnvVars` slice
- Update the `EnvVars` slice to include `PROXY_` prefix when needed
- Modify the `EnvVars` slice to include `PLUGIN_SSH_CIPHERS` as `PROXY_SSH_CIPHERS`
- Modify the `EnvVars` slice to include `PLUGIN_PROXY_USE_INSECURE_CIPHER` as `PROXY_SSH_USE_INSECURE_CIPHER`
- Modify the `EnvVars` slice to include `PLUGIN_PROXY_FINGERPRINT` as `PROXY_SSH_FINGERPRINT`
- Remove the environment variable `PROXY_HOST`
- Modify the `EnvVars` slice to include `PLUGIN_DEBUG` as `INPUT_DEBUG`

* appleboy/ssh-action#53 (comment)
* appleboy/ssh-action#32 (comment)
* appleboy/ssh-action#213
@muhammad-irfan-tahir
Copy link

muhammad-irfan-tahir commented Nov 16, 2023

  • name: ssh proxy command
    uses: appleboy/ssh-action@v1.0.0
    with:
    host: ${{ secrets.HOST }}
    username: ${{ secrets.USERNAME }}
    key: ${{ secrets.KEY }}
    port: ${{ secrets.PORT }}
    proxy_host: ${{ secrets.PROXY_HOST }}
    proxy_username: ${{ secrets.PROXY_USERNAME }}
    proxy_key: ${{ secrets.PROXY_KEY }}
    proxy_port: ${{ secrets.PROXY_PORT }}
    script: |
    mkdir abc
    ls -al

Getting this

2023/[1](https://github.com/newrichnetwork/wicked-graiphics-app/actions/runs/6895910138/job/18760904838#step:4:1)1/16 20:06:21 dial tcp ***:***: i/o timeout

If I remove PROXY Part it will work till Bastion but for proxy it start giving timeout

This is my ssh cnfg and it's working fine from here

Host NEWRICH-BASTION
Hostname X.X.X.X
User ubuntu
IdentityFile ~/work/ssh-keys/BASTION.pem

Host APP-Graphics-CO
Hostname 10.0.8.146
User ubuntu
ProxyJump NEWRICH-BASTION
ProxyCommand ssh jump route -T 1 exec nc %h %p
IdentityFile ~/work/ssh-keys/NEWRICH-KEY.pem

What exactly is the error I'm not getting it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests