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

dmsgcurl exits without error on failure to connect or http error #261

Open
0pcom opened this issue Apr 6, 2024 · 1 comment
Open

dmsgcurl exits without error on failure to connect or http error #261

0pcom opened this issue Apr 6, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@0pcom
Copy link
Collaborator

0pcom commented Apr 6, 2024

When using dmsgcurl via script to check a visor's /health over dmsg in order to determine if one should create a transport to that visor or if that visor can be reached over dmsg, it's critical that the exit status of dmsgcurl should more reflect the behavior of curl in the same instance.

$ skywire dmsg curl -l debug dmsg://$(skywire cli config gen-keys | head -n1):80/health ; echo "Exit status $?"
[2024-04-06T10:23:56.860428249-05:00] DEBUG disc.NewHTTP [dmsgcurl]: Created HTTP client. addr="http://dmsgd.skywire.skycoin.com"
[2024-04-06T10:23:56.860467083-05:00] DEBUG [dmsgcurl]: Connecting to dmsg network... dmsg_disc="http://dmsgd.skywire.skycoin.com" public_key="020dd574b5fbeac3f2865ea3cf7080eaf48671e447df5182f1d2b488f2c7ceb957"
[2024-04-06T10:23:56.860529004-05:00] DEBUG [dmsg_client]: Discovering dmsg servers...
[2024-04-06T10:23:57.376771725-05:00] DEBUG [dmsg_client]: Dialing session... remote_pk=03717576ada5b1744e395c66c2bb11cea73b0e23d0dcd54422139b1a7f12e962c4
[2024-04-06T10:23:58.200998802-05:00] DEBUG [dmsg_client]: Serving session. remote_pk=03717576ada5b1744e395c66c2bb11cea73b0e23d0dcd54422139b1a7f12e962c4
[2024-04-06T10:23:58.201058547-05:00] DEBUG [dmsgcurl]: Dmsg network ready.
[2024-04-06T10:23:58.696210807-05:00] ERROR [dmsgcurl]: error="failed to connect to HTTP server: Get "dmsg://02153a3aa4424a745b54fa550b083e91c627abe07299619f24ef6611e26dda45fa:80/health": dmsg error 100 - entry is not found in discovery"
[2024-04-06T10:23:58.696453651-05:00] DEBUG [dmsg_client]: Stopped accepting streams. error="session shutdown" session=03717576ada5b1744e395c66c2bb11cea73b0e23d0dcd54422139b1a7f12e962c4
[2024-04-06T10:23:58.696461474-05:00] DEBUG [dmsg_client]: Stopped serving client!
[2024-04-06T10:23:58.696533555-05:00] DEBUG [dmsg_client]: Session closed. error=<nil>
[2024-04-06T10:23:58.696568164-05:00] DEBUG [dmsg_client]: All sessions closed.
[2024-04-06T10:23:58.934299388-05:00] DEBUG [dmsg_client]: Deleting entry. entry=	version: 0.0.1
	sequence: 0
	registered at: 1712417037945352160
	static public key: 020dd574b5fbeac3f2865ea3cf7080eaf48671e447df5182f1d2b488f2c7ceb957
	signature: e91b16e760291f5b7db9e973ad35ec270d3fd7a5a742daf51a152280b190774f1bde5b54ea76816a4c4e764e1786f99622f91ab0ab6aba8466b37f2f757294c700
	entry is registered as client. Related info: 
		delegated servers: 
			03717576ada5b1744e395c66c2bb11cea73b0e23d0dcd54422139b1a7f12e962c4


[2024-04-06T10:23:59.178884521-05:00] DEBUG [dmsg_client]: Entry Deleted successfully.
[2024-04-06T10:23:59.178932201-05:00] DEBUG [dmsgcurl]: Disconnected from dmsg network. error=<nil>

Exit status 0

For comparison, the behavior of curl when a website is not found

$ curl -L http://nonexistantwebsite.com/ ; echo "Exit status: $?"
curl: (6) Could not resolve host: nonexistantwebsite.com
Exit status: 6
@0pcom 0pcom added the bug Something isn't working label Apr 6, 2024
@0pcom
Copy link
Collaborator Author

0pcom commented Apr 7, 2024

I've come up with a workaround using dmsgweb which is much faster than dmsgcurl when it comes to bulk downloads

$ curl -Lx socks5h://127.0.0.1:4445 http://$(skywire cli visor pk).dmsg/health 
{"build_info":{"version":"v1.3.20","commit":"8e782b1","date":"2024-03-23T01:29:00Z"},"started_at":"2024-04-06T12:41:54.253875421-05:00"}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant