Commit graph

27 commits

Author SHA1 Message Date
Dave Collins
bbec5f3a91 Update websocket import paths to new location. 2015-01-15 17:25:14 -06:00
Dave Collins
c74bb4e087 Update license year to 2015. 2015-01-03 02:24:28 -06:00
Javed Khan
331f25f506 compatiblity hack for blockchain.info getbalance 2014-09-10 21:22:09 +05:30
Josh Rickmar
160a843171 Allow websocket conns to be established after New.
ok @davecgh
2014-07-25 13:17:43 -05:00
Dave Collins
656fa8699b Improve disconnect and shutdown handling.
Previously the exported Disconnect and Shutdown functions called each other
and therefore needed to release and reacquire the locks which could
potentionally allow a request to sneak in between the lock and unlock.

This commit changes the exported Shutdown function so that everything is
done under the request lock to prevent this possibility.  In order to
support this, the shared code between the Disconnect and Shutdown
functions has been refactored into unexported functions and the locking
has been altered accordingly.

Also, replace the sendMessage function with a select over the send and
disconnect channels to prevent any issues with queued up messages.

joint debugging effort between myself and @jrick
2014-07-07 21:58:13 -05:00
Josh Rickmar
1a23feb53e Fix hang on new request receives after shutdown.
Previously, requests could still be sent to a shutdown client and
added to the client's internal data structures, without ever
responding to the future with an error for a shutdown client (causing
hangs when blocking on the future receive).  This change fixes this by
performing a non-blocking read of the client's shutdown channel before
adding a request, and responding with the shutdown error if the client
has begun or completed its shutdown.

ok @davecgh
2014-07-07 19:11:50 -05:00
Dave Collins
1a866200e3 Improve websocket connection error handling.
This commit modifies the error handling for websocket connections to fall
back to returning the status text returned from the server if the
handshake fails and it's not due to an authentication or invalid endpoint.
2014-07-03 12:31:53 -05:00
Tomás Senart
77fdb1011b Handle non successfull HTTP responses
This change set equips the RPC client with handling of non successful
HTTP responses. An HTTP response is considered non successful when its
status code is not in the range 200..299
2014-07-03 18:54:50 +02:00
Dave Collins
0e463baf95 goimports -w . 2014-07-02 19:34:05 -05:00
Dave Collins
a9e1b8fb84 Use system CAs when Certificates are not specified.
This commit modifies the TLS setup to only override the RootCAs for the
TLS connection if certificates are specified.  This allows the
Certificates parameter to be ommitted from the connection config to use
the system CAs.
2014-06-25 21:53:00 -05:00
David Hill
0ae3676a7d Log when the initial connection has been made. 2014-06-25 12:56:47 -04:00
Josh Rickmar
22b6af1400 Fix unmarshaling of HTTP POST responses.
If connecting to a bitcoin RPC server as an HTTP POST client, full
response objects rather than just the raw result bytes were being
passed to the specific result unmarshalers, causing unmarshal errors
for the incorrect JSON types.  To fix this, first unmarshal the
response body into a rawResponse, and pass only the raw result bytes
(or an error) to the specific handlers.

This was reported by nskelsey on IRC.

ok @davecgh
2014-06-18 10:21:18 -05:00
Dave Collins
7448f9555c Make golint happier. 2014-06-12 23:00:03 -05:00
Josh Rickmar
28c0a3c8c7 Modify doco and example for btcwallet ws endpoint. 2014-06-12 13:00:42 -05:00
Josh Rickmar
4ac778d72a Do not reissue rescan requests on reconnect. 2014-06-12 11:38:22 -05:00
Josh Rickmar
1ec6dde39c Add custom/raw request/response support. 2014-06-11 16:38:54 -05:00
Josh Rickmar
793e66c785 Add callback for connects and reconnects. 2014-06-11 16:38:54 -05:00
Dave Collins
8e624b20a9 Switch to conformal vendoring of Gorilla websocket. 2014-06-07 01:06:11 -05:00
kargakis
a785ef6424 minor syntax fixes 2014-06-02 17:31:02 +03:00
Dave Collins
a35c1e8ede Auto recreate notification state on reconnect.
This commit adds logic to track all registered notifications that have
been registered by the client in a notification state when the default
automatic reconnect is enabled.

The notification state is then used to reregister for all previously
registered notifications on reconnect.  This allows the caller to
continue receiving notifications across reconnect cycles.
2014-05-10 02:15:09 -05:00
Dave Collins
8700eeaeb6 Convert to use gorilla websockets package.
Also, since the new package exposes more connection related error
information, add a new ErrInvalidEndpoint which is returned if the
specified enpoint does not appear to be a valid websocket provider and
only return the ErrInvalidAuth error when HTTP authorization failure
status codes are detected.

Closes #1.
2014-05-09 19:57:58 -05:00
Dave Collins
2fc983ece1 Finish the comment on the Disconnect function. 2014-05-08 13:10:09 -05:00
Dave Collins
6825e68c59 Use uint64 for the request ID instead of int64.
There is no reason for the request ID to be signed.  Pointed out by
@jrick.
2014-05-08 13:05:31 -05:00
Dave Collins
7c552136bc Move Disconnected next to Disconnect func. 2014-05-07 11:23:35 -05:00
Dave Collins
1122a8a9cb Remove leftover testing sleep. 2014-05-07 11:23:27 -05:00
Dave Collins
cf409a8d79 Disconnect client on shutdown. 2014-05-07 11:19:30 -05:00
Dave Collins
e3f130ade5 Initial commit. 2014-05-07 11:14:39 -05:00