Blockscout: Blockscout cant connect to Parity - WS Error <Http(Token)>: Invalid byte where token is required.

Created on 20 Sep 2018  Â·  14Comments  Â·  Source: blockscout/blockscout

Blockscout cannot seem to connect to local Parity to read Ethereum mainnet block data.

Environment

Ubuntu 16
All prerequisites exactly as per install procedure
Parity-Ethereum/v2.0.4-beta-e2e1d22-20180910/x86_64-linux-gnu/rustc1.28.0

Indexer config

use Mix.Config

config :indexer,
  block_interval: 5_000,
  json_rpc_named_arguments: [
    transport: EthereumJSONRPC.HTTP,
    transport_options: [
      http: EthereumJSONRPC.HTTP.HTTPoison,
      url: "http://localhost:8545",
      method_to_url: [
        eth_getBalance: "http://localhost:8545",
        trace_replayTransaction: "http://localhost:8545"
      ],
      http_options: [recv_timeout: 60_000, timeout: 60_000, hackney: [pool: :ethereum_jsonrpc]]
    ],
    variant: EthereumJSONRPC.Parity
  ],
  subscribe_named_arguments: [
    transport: EthereumJSONRPC.WebSocket,
    transport_options: [
      web_socket: EthereumJSONRPC.WebSocket.WebSocketClient,
      url: "wss://localhost:8546"
    ]
  ]

Steps to reproduce

I have an ethereum main net Parity running on the same machine as blockscout. For the purposes of trouble shooting this, parity is launched with the following unsecured parameters - exposing api etc to everyone.

Start parity with:
parity --jsonrpc-cors all --ws-origins all --ws-hosts all --ws-interface all --jsonrpc-interface all --unsafe-expose --jsonrpc-apis all --ui-no-validation --ui-interface 0.0.0.0
Fresh build of Blockscout

mix phx.server

Expected behaviour

Blockscout should start and operate same style as POS but with Ethereum blockchain data.

Actual behaviour

The Parity terminal outputs this error shortly after mix phx.server is started

2018-09-19 22:46:32  WS Error <Http(Token)>: Invalid byte where token is required.
2018-09-19 22:46:34  WS Error <Http(Token)>: Invalid byte where token is required.
2018-09-19 22:46:34  WS Error <Http(Token)>: Invalid byte where token is required.
2018-09-19 22:46:34  WS Error <Http(Token)>: Invalid byte where token is required.
2018-09-19 22:46:34  WS Error <Http(Token)>: Invalid byte where token is required.
2018-09-19 22:46:34  WS Error <Http(Token)>: Invalid byte where token is required.
2018-09-19 22:46:35  WS Error <Http(Token)>: Invalid byte where token is required.
2018-09-19 22:46:35  WS Error <Http(Token)>: Invalid byte where token is required.
2018-09-19 22:46:35  WS Error <Http(Token)>: Invalid byte where token is required.
2018-09-19 22:46:36  WS Error <Http(Token)>: Invalid byte where token is required.

After a minute or so blockscout crashes with

``` mix phx.server Failed to watch /root/blockscout; upper limit on inotify watches reached! Please increase the amount of inotify watches allowed per user via/proc/sys/fs/inotify/max_user_watches'.
22:06:13.690 application=phoenix [info] Running BlockScoutWeb.Endpoint with Cowboy using http://0.0.0.0:4000

webpack is watching the files…

* (exit) exited in: GenServer.call(Mix.State, {:update, {Map, :put, [:env, :dev]}}, 5000)
*
(EXIT) time out
(elixir) lib/gen_server.ex:924: GenServer.call/3
(mix) lib/mix/dep.ex:274: Mix.Dep.in_dependency/3
(elixir) lib/enum.ex:765: Enum."-each/2-lists^foreach/1-0-"/2
(elixir) lib/enum.ex:765: Enum.each/2
(phoenix) lib/phoenix/code_reloader/server.ex:53: anonymous fn/1 in Phoenix.CodeReloader.Server.handle_call/3
(phoenix) lib/phoenix/code_reloader/server.ex:187: Phoenix.CodeReloader.Server.proxy_io/1
(phoenix) lib/phoenix/code_reloader/server.ex:51: Phoenix.CodeReloader.Server.handle_call/3
(stdlib) gen_server.erl:661: :gen_server.try_handle_call/4
(stdlib) gen_server.erl:690: :gen_server.handle_msg/6
(stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3

22:07:21.681 application=phoenix [info] JOIN "exchange_rate:new_rate" to BlockScoutWeb.ExchangeRateChannel
Transport: Phoenix.Transports.WebSocket (2.0.0)
Serializer: Phoenix.Transports.V2.WebSocketSerializer
Parameters: %{}
22:07:22.234 application=phoenix [info] Replied exchange_rate:new_rate :ok
22:07:25.837 application=phoenix [info] JOIN "transactions:new_transaction" to BlockScoutWeb.TransactionChannel
Transport: Phoenix.Transports.WebSocket (2.0.0)
Serializer: Phoenix.Transports.V2.WebSocketSerializer
Parameters: %{}
22:07:25.846 application=phoenix [info] Replied transactions:new_transaction :ok
22:07:25.847 application=phoenix [info] JOIN "exchange_rate:new_rate" to BlockScoutWeb.ExchangeRateChannel
Transport: Phoenix.Transports.WebSocket (2.0.0)
Serializer: Phoenix.Transports.V2.WebSocketSerializer
Parameters: %{}
22:07:25.850 application=phoenix [info] Replied exchange_rate:new_rate :ok
22:07:25.852 application=phoenix [info] JOIN "transactions:new_transaction" to BlockScoutWeb.TransactionChannel
Transport: Phoenix.Transports.WebSocket (2.0.0)
Serializer: Phoenix.Transports.V2.WebSocketSerializer
Parameters: %{}
22:07:25.854 application=phoenix [info] Replied transactions:new_transaction :ok
22:07:25.858 application=phoenix [info] JOIN "exchange_rate:new_rate" to BlockScoutWeb.ExchangeRateChannel
Transport: Phoenix.Transports.WebSocket (2.0.0)
Serializer: Phoenix.Transports.V2.WebSocketSerializer
Parameters: %{}
22:07:25.861 application=phoenix [info] Replied exchange_rate:new_rate :ok
22:07:25.869 application=phoenix [info] JOIN "transactions:new_transaction" to BlockScoutWeb.TransactionChannel
Transport: Phoenix.Transports.WebSocket (2.0.0)
Serializer: Phoenix.Transports.V2.WebSocketSerializer
Parameters: %{}
22:07:25.872 application=phoenix [info] Replied transactions:new_transaction :ok
22:07:25.873 application=phoenix [info] JOIN "exchange_rate:new_rate" to BlockScoutWeb.ExchangeRateChannel
Transport: Phoenix.Transports.WebSocket (2.0.0)
Serializer: Phoenix.Transports.V2.WebSocketSerializer
Parameters: %{}
22:07:25.876 application=phoenix [info] Replied exchange_rate:new_rate :ok
22:07:25.879 application=phoenix [info] JOIN "transactions:new_transaction" to BlockScoutWeb.TransactionChannel
Transport: Phoenix.Transports.WebSocket (2.0.0)
Serializer: Phoenix.Transports.V2.WebSocketSerializer
Parameters: %{}
22:07:25.884 application=phoenix [info] Replied transactions:new_transaction :ok
22:07:29.870 [info] Application indexer exited: shutdown
22:07:25.872 application=phoenix [info] Replied transactions:new_transaction :ok
22:07:25.873 application=phoenix [info] JOIN "exchange_rate:new_rate" to BlockScoutWeb.ExchangeRateChannel
Transport: Phoenix.Transports.WebSocket (2.0.0)
Serializer: Phoenix.Transports.V2.WebSocketSerializer
Parameters: %{}
22:07:25.876 application=phoenix [info] Replied exchange_rate:new_rate :ok
22:07:25.879 application=phoenix [info] JOIN "transactions:new_transaction" to BlockScoutWeb.TransactionChannel
Transport: Phoenix.Transports.WebSocket (2.0.0)
Serializer: Phoenix.Transports.V2.WebSocketSerializer
Parameters: %{}
22:07:25.884 application=phoenix [info] Replied transactions:new_transaction :ok
22:07:29.870 [info] Application indexer exited: shutdown
Hash: b17b94b9792664a20fa2
Version: webpack 4.14.0
Time: 626245ms
Built at: 09/19/2018 10:17:42 PM
Asset Size Chunks Chunk Names
../images/block.svg 1.53 KiB [emitted]
../fonts/fa-brands-400.eot 112 KiB [emitted]
../fonts/fa-brands-400.ttf 112 KiB [emitted]
../fonts/fa-brands-400.woff 72.2 KiB [emitted]
../fonts/fa-brands-400.woff2 61.9 KiB [emitted]
../fonts/fa-regular-400.eot 39.8 KiB [emitted]
../fonts/fa-regular-400.svg 138 KiB [emitted]
../fonts/fa-regular-400.ttf 39.6 KiB [emitted]
../fonts/fa-regular-400.woff 17.8 KiB [emitted]
../fonts/fa-regular-400.woff2 14.6 KiB [emitted]
../fonts/fa-solid-900.eot 157 KiB [emitted]
../fonts/fa-solid-900.svg 579 KiB [emitted]
../fonts/fa-solid-900.ttf 157 KiB [emitted]
../fonts/fa-solid-900.woff 74.8 KiB [emitted]
../fonts/fa-solid-900.woff2 58.2 KiB [emitted]
app.js 2.91 MiB main [emitted] main
../css/app.css 269 KiB main [emitted] main
../favicon.ico 1.23 KiB [emitted]
../images/average_time.svg 1.78 KiB [emitted]
../fonts/fa-brands-400.svg 608 KiB [emitted]
../images/blocks.svg 2.61 KiB [emitted]
../images/classic_logo.svg 4.87 KiB [emitted]
../images/eth.png 3.66 KiB [emitted]
../images/ethereum_logo.svg 3.46 KiB [emitted]
../images/last_block.svg 1.6 KiB [emitted]
../images/logo.svg 935 bytes [emitted]
../images/poa_logo.svg 1.05 KiB [emitted]
../images/purple-block.svg 1.53 KiB [emitted]
../images/smart_contract.svg 2.08 KiB [emitted]
../images/sokol_logo.svg 3.42 KiB [emitted]
../images/ropsten_logo.svg 4.13 KiB [emitted]
../images/token.svg 2.41 KiB [emitted]
../images/transaction.svg 494 bytes [emitted]
../images/transactions.svg 983 bytes [emitted]
../robots.txt 202 bytes [emitted]
../images/classic_ethereum_logo.svg 8.29 KiB [emitted]
../images/ethereum.png 13.7 KiB [emitted]
../images/kovan_logo.svg 33.5 KiB [emitted]
../images/rinkeby_logo.svg 33.7 KiB [emitted]
[../../../deps/phoenix_html/priv/static/phoenix_html.js] /root/blockscout/deps/phoenix_html/priv/static/phoenix_html.js 1.2 KiB {main} [built]
[./js/app.js] 718 bytes {main} [built]
[./js/lib/clipboard_buttons.js] 668 bytes {main} [built]
[./js/lib/currency.js] 2.52 KiB {main} [built]
[./js/lib/from_now.js] 1.14 KiB {main} [built]
[./js/lib/loading_element.js] 340 bytes {main} [built]
[./js/lib/market_history_chart.js] 4.91 KiB {main} [built]
[./js/lib/pretty_json.js] 475 bytes {main} [built]
[./js/lib/reload_button.js] 310 bytes {main} [built]
[./js/lib/smart_contract/read_only_functions.js] 1.55 KiB {main} [built]
[./js/lib/stop_propagation.js] 317 bytes {main} [built]
[./js/lib/token_balance_dropdown.js] 995 bytes {main} [built]
[./js/lib/token_transfers_toggle.js] 961 bytes {main} [built]
[./js/lib/tooltip.js] 296 bytes {main} [built]
[./js/pages/transaction.js] 6.28 KiB {main} [built]
+ 553 hidden modules
Child extract-text-webpack-plugin node_modules/extract-text-webpack-plugin/dist node_modules/css-loader/index.js!node_modules/postcss-loader/lib/index.js!node_modules/sass-loader/lib/loader.js??ref--5-4!css/app.scss:
15 assets
[./node_modules/css-loader/index.js!./node_modules/postcss-loader/lib/index.js!./node_modules/sass-loader/lib/loader.js??ref--5-4!./css/app.scss] ./node_modules/css-loader!./node_modules/postcss-loader/lib!./node_modules/sass-loader/lib/loader.js??ref--5-4!./css/app.scss 285 KiB {0} [built]
+ 17 hidden modules
22:24:42.286 application=plug [error] Cowboy returned 400 and there are no headers in the connection.

This may happen if Cowboy is unable to parse the request headers,
for example, because there are too many headers or the header name
or value are too large (such as a large cookie).

You can customize those values when configuring your http/https
server. The configuration option and default values are shown below:

protocol_options: [
  max_header_name_length: 64,
  max_header_value_length: 4096,
  max_headers: 100
]


*Tell us what happens instead.*

If it helps, here's the headers when trying to connect to websocket

Request URL: ws://localhost:4000/socket/websocket?locale=en&vsn=2.0.0
Request Method: GET
Status Code: 101 Switching Protocols
connection: Upgrade
sec-websocket-accept: 1o1AUiKECbuMh/xbofPoLhXk0Rg=
upgrade: websocket
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.9
Cache-Control: no-cache
Connection: Upgrade
Host: localhost:4000
Origin: http://localhost:4000
Pragma: no-cache
Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits
Sec-WebSocket-Key: jArg3WrF92NKagK0SJLrnQ==
Sec-WebSocket-Version: 13
Upgrade: websocket
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36
locale: en
vsn: 2.0.0`
```

As above

Any help would be great - thanks

bug waiting on review

Most helpful comment

I've experienced the same issue with the WS Error <Http(Token)>: Invalid byte where token is required..

All 14 comments

@ImrieA It doesn't look like you have tracing enabled on your node. I'll attempt to replicate over the next few days.

Thanks @acravenho , tracing is on . But looks like I didn't realize Parity starts with pruning by default these days... After disabling that it shows blocks in the Blockscout explorer but the WS error in the subject of this issue still remains.

```

nano ~/.local/share/io.parity.ethereum/chains/ethereum/user_defaults

{"is_first_launch":false,"pruning":"archive","tracing":true,"fat_db":false,"mode":"active"}

```

Here's the output after disabling pruning. It seems to have properly indexed a few thousand blocks and stopped. Now whenever I start the explorer it outputs the below

mix phx.server
Failed to watch /root/blockscout; upper limit on inotify watches reached!
Please increase the amount of inotify watches allowed per user via `/proc/sys/fs/inotify/max_user_watches'.
04:21:08.010 application=phoenix [info] Running BlockScoutWeb.Endpoint with Cowboy using http://0.0.0.0:4000
04:21:18.314 application=phoenix [info] JOIN "exchange_rate:new_rate" to BlockScoutWeb.ExchangeRateChannel
  Transport:  Phoenix.Transports.WebSocket (2.0.0)
  Serializer:  Phoenix.Transports.V2.WebSocketSerializer
  Parameters: %{}
04:21:18.616 application=phoenix [info] Replied exchange_rate:new_rate :ok

webpack is watching the files…

04:21:58.640 application=phoenix [info] JOIN "exchange_rate:new_rate" to BlockScoutWeb.ExchangeRateChannel
  Transport:  Phoenix.Transports.WebSocket (2.0.0)
  Serializer:  Phoenix.Transports.V2.WebSocketSerializer
  Parameters: %{}
04:21:58.667 application=phoenix [info] Replied exchange_rate:new_rate :ok
04:22:32.653 application=phoenix [info] JOIN "exchange_rate:new_rate" to BlockScoutWeb.ExchangeRateChannel
  Transport:  Phoenix.Transports.WebSocket (2.0.0)
  Serializer:  Phoenix.Transports.V2.WebSocketSerializer
  Parameters: %{}
04:22:32.676 application=phoenix [info] Replied exchange_rate:new_rate :ok
04:22:32.678 application=phoenix [info] JOIN "addresses:0xbb7b8287f3f0a933474a79eae42cbca977791171" to BlockScoutWeb.AddressChannel
  Transport:  Phoenix.Transports.WebSocket (2.0.0)
  Serializer:  Phoenix.Transports.V2.WebSocketSerializer
  Parameters: %{}
04:22:32.687 application=phoenix [info] Replied addresses:0xbb7b8287f3f0a933474a79eae42cbca977791171 :ok
Hash: b17b94b9792664a20fa2
Version: webpack 4.14.0
Time: 105160ms
Built at: 09/20/2018 4:23:05 AM
                              Asset       Size  Chunks             Chunk Names
         ../images/average_time.svg   1.78 KiB          [emitted]
         ../fonts/fa-brands-400.eot    112 KiB          [emitted]
         ../fonts/fa-brands-400.ttf    112 KiB          [emitted]
        ../fonts/fa-brands-400.woff   72.2 KiB          [emitted]
       ../fonts/fa-brands-400.woff2   61.9 KiB          [emitted]
        ../fonts/fa-regular-400.eot   39.8 KiB          [emitted]
        ../fonts/fa-regular-400.svg    138 KiB          [emitted]
        ../fonts/fa-regular-400.ttf   39.6 KiB          [emitted]
       ../fonts/fa-regular-400.woff   17.8 KiB          [emitted]
      ../fonts/fa-regular-400.woff2   14.6 KiB          [emitted]
          ../fonts/fa-solid-900.eot    157 KiB          [emitted]
          ../fonts/fa-solid-900.svg    579 KiB          [emitted]
          ../fonts/fa-solid-900.ttf    157 KiB          [emitted]
         ../fonts/fa-solid-900.woff   74.8 KiB          [emitted]
        ../fonts/fa-solid-900.woff2   58.2 KiB          [emitted]
                             app.js   2.91 MiB    main  [emitted]  main
                     ../css/app.css    269 KiB    main  [emitted]  main
                     ../favicon.ico   1.23 KiB          [emitted]
               ../images/blocks.svg   2.61 KiB          [emitted]
         ../fonts/fa-brands-400.svg    608 KiB          [emitted]
                ../images/block.svg   1.53 KiB          [emitted]
                  ../images/eth.png   3.66 KiB          [emitted]
         ../images/classic_logo.svg   4.87 KiB          [emitted]
        ../images/ethereum_logo.svg   3.46 KiB          [emitted]
           ../images/last_block.svg    1.6 KiB          [emitted]
                 ../images/logo.svg  935 bytes          [emitted]
             ../images/poa_logo.svg   1.05 KiB          [emitted]
         ../images/purple-block.svg   1.53 KiB          [emitted]
         ../images/ropsten_logo.svg   4.13 KiB          [emitted]
       ../images/smart_contract.svg   2.08 KiB          [emitted]
           ../images/sokol_logo.svg   3.42 KiB          [emitted]
                ../images/token.svg   2.41 KiB          [emitted]
../images/classic_ethereum_logo.svg   8.29 KiB          [emitted]
             ../images/ethereum.png   13.7 KiB          [emitted]
          ../images/transaction.svg  494 bytes          [emitted]
         ../images/transactions.svg  983 bytes          [emitted]
                      ../robots.txt  202 bytes          [emitted]
           ../images/kovan_logo.svg   33.5 KiB          [emitted]
         ../images/rinkeby_logo.svg   33.7 KiB          [emitted]
[../../../deps/phoenix_html/priv/static/phoenix_html.js] /root/blockscout/deps/phoenix_html/priv/static/phoenix_html.js 1.2 KiB {main} [built]
[./js/app.js] 718 bytes {main} [built]
[./js/lib/clipboard_buttons.js] 668 bytes {main} [built]
[./js/lib/currency.js] 2.52 KiB {main} [built]
[./js/lib/from_now.js] 1.14 KiB {main} [built]
[./js/lib/loading_element.js] 340 bytes {main} [built]
[./js/lib/market_history_chart.js] 4.91 KiB {main} [built]
[./js/lib/pretty_json.js] 475 bytes {main} [built]
[./js/lib/reload_button.js] 310 bytes {main} [built]
[./js/lib/smart_contract/read_only_functions.js] 1.55 KiB {main} [built]
[./js/lib/stop_propagation.js] 317 bytes {main} [built]
[./js/lib/token_balance_dropdown.js] 995 bytes {main} [built]
[./js/lib/token_transfers_toggle.js] 961 bytes {main} [built]
[./js/lib/tooltip.js] 296 bytes {main} [built]
[./js/pages/transaction.js] 6.28 KiB {main} [built]
    + 553 hidden modules
Child extract-text-webpack-plugin node_modules/extract-text-webpack-plugin/dist node_modules/css-loader/index.js!node_modules/postcss-loader/lib/index.js!node_modules/sass-loader/lib/loader.js??ref--5-4!css/app.scss:
     15 assets
    [./node_modules/css-loader/index.js!./node_modules/postcss-loader/lib/index.js!./node_modules/sass-loader/lib/loader.js??ref--5-4!./css/app.scss] ./node_modules/css-loader!./node_modules/postcss-loader/lib!./node_modules/sass-loader/lib/loader.js??ref--5-4!./css/app.scss 285 KiB {0} [built]
        + 17 hidden modules
04:23:18.944 [info] Application indexer exited: shutdown

@ImrieA Is there anything in your logs/dev/errors.log or logs/dev/indexer.log files?

@acravenho
Both these files are empty

@ImrieA It's 100% a node issue. I should have some time this weekend to provide the exact settings to configure for your node. We've had many changes over the last couple months to our nodes but this is something we need to provide better documentation for.

That would be great, thanks for the help

I've experienced the same issue with the WS Error <Http(Token)>: Invalid byte where token is required..

yeah i had a working block scout but now it seems to be broken since now im getting the same error may be due to a new parity version since i started having issues after i swapped my parity. its due to the websocket wanting the token output by the command parity signer new-token i have yet to find a way to disable it. im going to try to backdate and see if that helps

@Alaradia What Parity version did you upgrade to? We have compatibility with < 1.11. We have not yet tested 2.0

yeah i went from a version im not sure what it was to 2 so that's probably the issue ill try 1.11.

@rsoutar @Alaradia Thanks for the help with this issue. I've created a new issue #818 for our teams to tackle in the next couple weeks. I'm going to close this issue for now and will reopen once we have full support for Parity 2.0 and this is not resolved.

i tried 1.11.1 and same error not sure if theirs some weird issue going on with some sort of system flag not stored in parity's directory im going to try nuking my test environment tomorrow and see if i can reproduce on a fresh install

Sounds good. Please keep us updated :+1:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SVINCHAIN picture SVINCHAIN  Â·  3Comments

igorffs picture igorffs  Â·  7Comments

pashagonchar picture pashagonchar  Â·  5Comments

zulhfreelancer picture zulhfreelancer  Â·  6Comments

shisoft picture shisoft  Â·  7Comments