k6

WebSocket reconnect exception

Hi,
I am running websocket testing with K6. However because of network issue, the websocket connection is not quite stable during the life cycle of websocket connection. So we are trying to reconnect the websocket once we received the message like “use of closed connection”. However, I always got the following exception if the network connection is not available. Is it possible that K6 just returns the error message instead of exception stopping the test so that we have opportunity to reconnect websocket for many times? Thanks for your help in advance.

INFO[0001] websocket connected                          -
INFO[0001] {"C":"d-9E633432-B,0|ed,0|ee,0|ef,1","S":1,"M":[]}
INFO[0009] {}                                           -
INFO[0011] Pinging every 10sec (setInterval test)       -
INFO[0019] {}                                           -
INFO[0021] Pinging every 10sec (setInterval test)       -
INFO[0031] Pinging every 10sec (setInterval test)       -
INFO[0041] Pinging every 10sec (setInterval test)       -
INFO[0051] An unexpected error occured:                  0="tls: use of closed connection"
INFO[0061] Connection Duration:                          0=60009-
INFO[0061] Exception and will reconnect in 10 secs
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
        panic: Panic at 24: runtime error: invalid memory address or nil pointer dereference [recovered]
        panic: Panic at 24: runtime error: invalid memory address or nil pointer dereference [recovered]
        panic: Panic at 11: Panic at 24: runtime error: invalid memory address or nil pointer dereference [recovered]
        panic: Panic at 11: Panic at 24: runtime error: invalid memory address or nil pointer dereference [recovered]
        panic: Panic at 6: Panic at 11: Panic at 24: runtime error: invalid memory address or nil pointer dereference [recovered]
        panic: Panic at 6: Panic at 11: Panic at 24: runtime error: invalid memory address or nil pointer dereference [recovered]
        panic: Panic at 11: Panic at 6: Panic at 11: Panic at 24: runtime error: invalid memory address or nil pointer dereference [recovered]
        panic: Panic at 11: Panic at 6: Panic at 11: Panic at 24: runtime error: invalid memory address or nil pointer dereference [recovered]
        panic: Panic at 48: Panic at 11: Panic at 6: Panic at 11: Panic at 24: runtime error: invalid memory address or nil pointer dereference [recovered]
        panic: Panic at 48: Panic at 11: Panic at 6: Panic at 11: Panic at 24: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x10 pc=0xc307fb]

goroutine 7 [running]:
github.com/loadimpact/k6/vendor/github.com/dop251/goja.AssertFunction.func1.1(0xc000731d68)
        /home/mstoykov/.gvm/pkgsets/go1.12.9/global/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/runtime.go:1407 +0xa2
panic(0xd49ba0, 0xc000420820)
        /home/mstoykov/.gvm/gos/go1.12.9/src/runtime/panic.go:522 +0x1c3
github.com/loadimpact/k6/vendor/github.com/dop251/goja.(*vm).try.func1(0xc001b9add0, 0x0, 0xc000731c70, 0x0, 0x0, 0x0, 0xc000731cc8)
        /home/mstoykov/.gvm/pkgsets/go1.12.9/global/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/vm.go:364 +0x495
panic(0xd49ba0, 0xc000420810)
        /home/mstoykov/.gvm/gos/go1.12.9/src/runtime/panic.go:522 +0x1c3
github.com/loadimpact/k6/vendor/github.com/dop251/goja.AssertFunction.func1.1(0xc000731398)
        /home/mstoykov/.gvm/pkgsets/go1.12.9/global/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/runtime.go:1407 +0xa2
panic(0xd49ba0, 0xc000420810)
        /home/mstoykov/.gvm/gos/go1.12.9/src/runtime/panic.go:522 +0x1c3
github.com/loadimpact/k6/vendor/github.com/dop251/goja.(*vm).try.func1(0xc001b9add0, 0x2, 0xc0007312a0, 0x6, 0x0, 0x0, 0xc0007312f8)
        /home/mstoykov/.gvm/pkgsets/go1.12.9/global/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/vm.go:364 +0x495
panic(0xd49ba0, 0xc000420800)
        /home/mstoykov/.gvm/gos/go1.12.9/src/runtime/panic.go:522 +0x1c3
github.com/loadimpact/k6/vendor/github.com/dop251/goja.AssertFunction.func1.1(0xc000730518)
        /home/mstoykov/.gvm/pkgsets/go1.12.9/global/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/runtime.go:1407 +0xa2
panic(0xd49ba0, 0xc000420800)
        /home/mstoykov/.gvm/gos/go1.12.9/src/runtime/panic.go:522 +0x1c3
github.com/loadimpact/k6/vendor/github.com/dop251/goja.(*vm).try.func1(0xc001b9add0, 0x5, 0xc000730420, 0x11, 0x0, 0x0, 0xc000730478)
        /home/mstoykov/.gvm/pkgsets/go1.12.9/global/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/vm.go:364 +0x495
panic(0xd49ba0, 0xc0004207f0)
        /home/mstoykov/.gvm/gos/go1.12.9/src/runtime/panic.go:522 +0x1c3
github.com/loadimpact/k6/vendor/github.com/dop251/goja.AssertFunction.func1.1(0xc00072fb20)
        /home/mstoykov/.gvm/pkgsets/go1.12.9/global/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/runtime.go:1407 +0xa2
panic(0xd49ba0, 0xc0004207f0)
        /home/mstoykov/.gvm/gos/go1.12.9/src/runtime/panic.go:522 +0x1c3
github.com/loadimpact/k6/vendor/github.com/dop251/goja.(*vm).try.func1(0xc001b9add0, 0x7, 0xc00072fa28, 0x16, 0x0, 0x0, 0xc00072fa80)
        /home/mstoykov/.gvm/pkgsets/go1.12.9/global/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/vm.go:364 +0x495
panic(0xd49ba0, 0xc0004207e0)
        /home/mstoykov/.gvm/gos/go1.12.9/src/runtime/panic.go:522 +0x1c3
github.com/loadimpact/k6/vendor/github.com/dop251/goja.AssertFunction.func1.1(0xc00072eca0)
        /home/mstoykov/.gvm/pkgsets/go1.12.9/global/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/runtime.go:1407 +0xa2
panic(0xd49ba0, 0xc0004207e0)
        /home/mstoykov/.gvm/gos/go1.12.9/src/runtime/panic.go:522 +0x1c3
github.com/loadimpact/k6/vendor/github.com/dop251/goja.(*vm).try.func1(0xc001b9add0, 0xa, 0xc00072eba8, 0x22, 0x0, 0x0, 0xc00072ec00)
        /home/mstoykov/.gvm/pkgsets/go1.12.9/global/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/vm.go:364 +0x495
panic(0xd5e1e0, 0x19d8460)
        /home/mstoykov/.gvm/gos/go1.12.9/src/runtime/panic.go:522 +0x1c3
github.com/loadimpact/k6/vendor/github.com/gorilla/websocket.(*Conn).WriteControl(0x0, 0x9, 0xc00072e360, 0x1, 0x20, 0xbf5155e697692550, 0x10a0f66ad5, 0x19ef480, 0x0, 0x0)
        /home/mstoykov/.gvm/pkgsets/go1.12.9/global/src/github.com/loadimpact/k6/vendor/github.com/gorilla/websocket/conn.go:412 +0x7b
github.com/loadimpact/k6/js/modules/k6/ws.(*Socket).Ping(0xc0011fec80)
        /home/mstoykov/.gvm/pkgsets/go1.12.9/global/src/github.com/loadimpact/k6/js/modules/k6/ws/ws.go:362 +0x178
reflect.callMethod(0xc0021ea9c0, 0xc00072e4b0, 0xc00072e498)
        /home/mstoykov/.gvm/gos/go1.12.9/src/reflect/value.go:690 +0x189
reflect.methodValueCall(0x0, 0x0, 0xc002296000, 0xc002296028, 0xc00072e6f0, 0x4c93a8, 0xc00189f050, 0xc0021ea9c0, 0x1a0c850, 0x0, ...)
        /home/mstoykov/.gvm/gos/go1.12.9/src/reflect/asm_amd64.s:35 +0x49
reflect.Value.call(0xd03400, 0xc0021ea9c0, 0x13, 0xe7ac24, 0x4, 0x1a0c850, 0x0, 0x0, 0xe72da0, 0x30001, ...)
        /home/mstoykov/.gvm/gos/go1.12.9/src/reflect/value.go:447 +0x468
reflect.Value.Call(0xd03400, 0xc0021ea9c0, 0x13, 0x1a0c850, 0x0, 0x0, 0x1069a66, 0x8c6aaf, 0xc0003dfc80)
        /home/mstoykov/.gvm/gos/go1.12.9/src/reflect/value.go:308 +0xab
github.com/loadimpact/k6/vendor/github.com/dop251/goja.(*Runtime).wrapReflectFunc.func1(0x10a30a0, 0xc0021b13c0, 0xc00227de60, 0x0, 0x18, 0x10a30a0, 0xc0021b17c0)
        /home/mstoykov/.gvm/pkgsets/go1.12.9/global/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/runtime.go:1153 +0x798
github.com/loadimpact/k6/vendor/github.com/dop251/goja.(*vm)._nativeCall(0xc001b9add0, 0xc0014ece70, 0x0)
        /home/mstoykov/.gvm/pkgsets/go1.12.9/global/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/vm.go:1826 +0x2a1
github.com/loadimpact/k6/vendor/github.com/dop251/goja.call.exec(0x0, 0xc001b9add0)
        /home/mstoykov/.gvm/pkgsets/go1.12.9/global/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/vm.go:1810 +0x4ab
github.com/loadimpact/k6/vendor/github.com/dop251/goja.(*vm).run(0xc001b9add0)
        /home/mstoykov/.gvm/pkgsets/go1.12.9/global/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/vm.go:288 +0x58
github.com/loadimpact/k6/vendor/github.com/dop251/goja.(*funcObject).Call(0xc0029eee40, 0x10a36e0, 0x1a0c500, 0xc000420690, 0x1, 0x1, 0xc00072eaf8, 0xc0003d6900)
        /home/mstoykov/.gvm/pkgsets/go1.12.9/global/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/func.go:130 +0x2cb
github.com/loadimpact/k6/vendor/github.com/dop251/goja.AssertFunction.func1.2()
        /home/mstoykov/.gvm/pkgsets/go1.12.9/global/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/runtime.go:1412 +0x9d
github.com/loadimpact/k6/vendor/github.com/dop251/goja.(*vm).try(0xc001b9add0, 0xc00072ec18, 0x0)
        /home/mstoykov/.gvm/pkgsets/go1.12.9/global/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/vm.go:370 +0x114
github.com/loadimpact/k6/vendor/github.com/dop251/goja.AssertFunction.func1(0x10a36e0, 0x1a0c500, 0xc000420690, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0)
        /home/mstoykov/.gvm/pkgsets/go1.12.9/global/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/runtime.go:1411 +0x114
github.com/loadimpact/k6/js/modules/k6/ws.(*WS).Connect(0x1a0c850, 0x1095600, 0xc0018a69c0, 0xc0000b6840, 0x15b, 0xc00221bd60, 0x2, 0x2, 0x0, 0x0, ...)
        /home/mstoykov/.gvm/pkgsets/go1.12.9/global/src/github.com/loadimpact/k6/js/modules/k6/ws/ws.go:196 +0x7b6
reflect.Value.call(0xd49f00, 0x1a0c850, 0x213, 0xe7ff8d, 0x9, 0xc002ee1130, 0x3, 0x3, 0xdf0d00, 0xc00041c3a0, ...)
        /home/mstoykov/.gvm/gos/go1.12.9/src/reflect/value.go:447 +0x468
reflect.Value.CallSlice(0xd49f00, 0x1a0c850, 0x213, 0xc002ee1130, 0x3, 0x3, 0x194, 0xc00072f5d0, 0x5)
        /home/mstoykov/.gvm/gos/go1.12.9/src/reflect/value.go:321 +0xab
github.com/loadimpact/k6/js/common.Bind.func1(0x10a30a0, 0xc002badc40, 0xc00227ddf0, 0x3, 0x1f, 0xc002edeb40, 0xc00072f7e8)
        /home/mstoykov/.gvm/pkgsets/go1.12.9/global/src/github.com/loadimpact/k6/js/common/bridge.go:239 +0x791
github.com/loadimpact/k6/vendor/github.com/dop251/goja.(*vm)._nativeCall(0xc001b9add0, 0xc0018c4630, 0x3)
        /home/mstoykov/.gvm/pkgsets/go1.12.9/global/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/vm.go:1826 +0x2a1
github.com/loadimpact/k6/vendor/github.com/dop251/goja.call.exec(0x3, 0xc001b9add0)
        /home/mstoykov/.gvm/pkgsets/go1.12.9/global/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/vm.go:1810 +0x4ab
github.com/loadimpact/k6/vendor/github.com/dop251/goja.(*vm).run(0xc001b9add0)
        /home/mstoykov/.gvm/pkgsets/go1.12.9/global/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/vm.go:288 +0x58
github.com/loadimpact/k6/vendor/github.com/dop251/goja.(*funcObject).Call(0xc0029e1bc0, 0x10a36e0, 0x1a0c500, 0xc000436d50, 0x1, 0x1, 0xd6ab00, 0xc0003d6900)
        /home/mstoykov/.gvm/pkgsets/go1.12.9/global/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/func.go:130 +0x2cb
github.com/loadimpact/k6/vendor/github.com/dop251/goja.AssertFunction.func1.2()
        /home/mstoykov/.gvm/pkgsets/go1.12.9/global/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/runtime.go:1412 +0x9d
github.com/loadimpact/k6/vendor/github.com/dop251/goja.(*vm).try(0xc001b9add0, 0xc00072fa98, 0x0)
        /home/mstoykov/.gvm/pkgsets/go1.12.9/global/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/vm.go:370 +0x114
github.com/loadimpact/k6/vendor/github.com/dop251/goja.AssertFunction.func1(0x10a36e0, 0x1a0c500, 0xc000436d50, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0)
        /home/mstoykov/.gvm/pkgsets/go1.12.9/global/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/runtime.go:1411 +0x114
github.com/loadimpact/k6/js/modules/k6/ws.(*Socket).handleEvent(0xc0011feb40, 0xe7bb80, 0x5, 0xc000436d50, 0x1, 0x1)
        /home/mstoykov/.gvm/pkgsets/go1.12.9/global/src/github.com/loadimpact/k6/js/modules/k6/ws/ws.go:336 +0xf5
github.com/loadimpact/k6/js/modules/k6/ws.(*Socket).Ping(0xc0011feb40)
        /home/mstoykov/.gvm/pkgsets/go1.12.9/global/src/github.com/loadimpact/k6/js/modules/k6/ws/ws.go:364 +0x232
reflect.callMethod(0xc0021ea5c0, 0xc00072fd28, 0xc00072fd10)
        /home/mstoykov/.gvm/gos/go1.12.9/src/reflect/value.go:690 +0x189
reflect.methodValueCall(0xd0f900, 0x1a0c850, 0xc002296000, 0xc003142a40, 0xc00072ff68, 0x4c93a8, 0xc00189f050, 0xc0021ea5c0, 0x1a0c850, 0x0, ...)
        /home/mstoykov/.gvm/gos/go1.12.9/src/reflect/asm_amd64.s:35 +0x49
reflect.Value.call(0xd03400, 0xc0021ea5c0, 0x13, 0xe7ac24, 0x4, 0x1a0c850, 0x0, 0x0, 0xe72da0, 0x30001, ...)
        /home/mstoykov/.gvm/gos/go1.12.9/src/reflect/value.go:447 +0x468
reflect.Value.Call(0xd03400, 0xc0021ea5c0, 0x13, 0x1a0c850, 0x0, 0x0, 0x1069a66, 0x8c6aaf, 0xc0003dfc80)
        /home/mstoykov/.gvm/gos/go1.12.9/src/reflect/value.go:308 +0xab
github.com/loadimpact/k6/vendor/github.com/dop251/goja.(*Runtime).wrapReflectFunc.func1(0x10a30a0, 0xc0031425c0, 0xc002f99240, 0x0, 0x8, 0x10a30a0, 0xc0021b0000)
        /home/mstoykov/.gvm/pkgsets/go1.12.9/global/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/runtime.go:1153 +0x798
github.com/loadimpact/k6/vendor/github.com/dop251/goja.(*vm)._nativeCall(0xc001b9add0, 0xc0014ec4d0, 0x0)
        /home/mstoykov/.gvm/pkgsets/go1.12.9/global/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/vm.go:1826 +0x2a1
github.com/loadimpact/k6/vendor/github.com/dop251/goja.call.exec(0x0, 0xc001b9add0)
        /home/mstoykov/.gvm/pkgsets/go1.12.9/global/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/vm.go:1810 +0x4ab
github.com/loadimpact/k6/vendor/github.com/dop251/goja.(*vm).run(0xc001b9add0)
        /home/mstoykov/.gvm/pkgsets/go1.12.9/global/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/vm.go:288 +0x58
github.com/loadimpact/k6/vendor/github.com/dop251/goja.(*funcObject).Call(0xc002a6e0c0, 0x10a36e0, 0x1a0c500, 0x0, 0x0, 0x0, 0x10a36e0, 0xc0003d6900)
        /home/mstoykov/.gvm/pkgsets/go1.12.9/global/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/func.go:130 +0x2cb
github.com/loadimpact/k6/vendor/github.com/dop251/goja.AssertFunction.func1.2()
        /home/mstoykov/.gvm/pkgsets/go1.12.9/global/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/runtime.go:1412 +0x9d
github.com/loadimpact/k6/vendor/github.com/dop251/goja.(*vm).try(0xc001b9add0, 0xc000730490, 0x0)
        /home/mstoykov/.gvm/pkgsets/go1.12.9/global/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/vm.go:370 +0x114
github.com/loadimpact/k6/vendor/github.com/dop251/goja.AssertFunction.func1(0x10a36e0, 0x1a0c500, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
        /home/mstoykov/.gvm/pkgsets/go1.12.9/global/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/runtime.go:1411 +0x114
github.com/loadimpact/k6/js/modules/k6/ws.(*WS).Connect(0x1a0c850, 0x1095600, 0xc0018a69c0, 0xc0000b6840, 0x15b, 0xc001ffb260, 0x2, 0x2, 0x0, 0x0, ...)
        /home/mstoykov/.gvm/pkgsets/go1.12.9/global/src/github.com/loadimpact/k6/js/modules/k6/ws/ws.go:269 +0x1804
reflect.Value.call(0xd49f00, 0x1a0c850, 0x213, 0xe7ff8d, 0x9, 0xc002f02550, 0x3, 0x3, 0xdf0d00, 0xc000f08970, ...)
        /home/mstoykov/.gvm/gos/go1.12.9/src/reflect/value.go:447 +0x468
reflect.Value.CallSlice(0xd49f00, 0x1a0c850, 0x213, 0xc002f02550, 0x3, 0x3, 0x194, 0xc0030c6e48, 0x5)
        /home/mstoykov/.gvm/gos/go1.12.9/src/reflect/value.go:321 +0xab
github.com/loadimpact/k6/js/common.Bind.func1(0x10a30a0, 0xc002badc40, 0xc002f991c0, 0x3, 0x10, 0xc002ed6fc0, 0xc0030c7060)
        /home/mstoykov/.gvm/pkgsets/go1.12.9/global/src/github.com/loadimpact/k6/js/common/bridge.go:239 +0x791
github.com/loadimpact/k6/vendor/github.com/dop251/goja.(*vm)._nativeCall(0xc001b9add0, 0xc0009d6630, 0x3)
        /home/mstoykov/.gvm/pkgsets/go1.12.9/global/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/vm.go:1826 +0x2a1
github.com/loadimpact/k6/vendor/github.com/dop251/goja.call.exec(0x3, 0xc001b9add0)
        /home/mstoykov/.gvm/pkgsets/go1.12.9/global/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/vm.go:1810 +0x4ab
github.com/loadimpact/k6/vendor/github.com/dop251/goja.(*vm).run(0xc001b9add0)
        /home/mstoykov/.gvm/pkgsets/go1.12.9/global/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/vm.go:288 +0x58
github.com/loadimpact/k6/vendor/github.com/dop251/goja.(*funcObject).Call(0xc002a47200, 0x10a36e0, 0x1a0c500, 0x0, 0x0, 0x0, 0xc001eee060, 0xc0003d6900)
        /home/mstoykov/.gvm/pkgsets/go1.12.9/global/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/func.go:130 +0x2cb
github.com/loadimpact/k6/vendor/github.com/dop251/goja.AssertFunction.func1.2()
        /home/mstoykov/.gvm/pkgsets/go1.12.9/global/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/runtime.go:1412 +0x9d
github.com/loadimpact/k6/vendor/github.com/dop251/goja.(*vm).try(0xc001b9add0, 0xc0030c7310, 0x0)
        /home/mstoykov/.gvm/pkgsets/go1.12.9/global/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/vm.go:370 +0x114
github.com/loadimpact/k6/vendor/github.com/dop251/goja.AssertFunction.func1(0x10a36e0, 0x1a0c500, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
        /home/mstoykov/.gvm/pkgsets/go1.12.9/global/src/github.com/loadimpact/k6/vendor/github.com/dop251/goja/runtime.go:1411 +0x114
github.com/loadimpact/k6/js/modules/k6.(*K6).Group(0x1a0c850, 0x1095600, 0xc0018a69c0, 0xc000222a87, 0x12, 0xc001ffb0e0, 0x0, 0x0, 0x0, 0x0)
        /home/mstoykov/.gvm/pkgsets/go1.12.9/global/src/github.com/loadimpact/k6/js/modules/k6/k6.go:90 +0x1b9
reflect.Value.call(0xda2860, 0x1a0c850, 0xa13, 0xe7ac24, 0x4, 0xc002f02230, 0x3, 0x3, 0xd6aa80, 0xce6fc0, ...)
        /home/mstoykov/.gvm/gos/go1.12.9/src/reflect/value.go:447 +0x468
reflect.Value.Call(0xda2860, 0x1a0c850, 0xa13, 0xc002f02230, 0x3, 0x3, 0x0, 0xe3d120, 0x5)
        /home/mstoykov/.gvm/gos/go1.12.9/src/reflect/value.go:308 +0xab
created by github.com/loadimpact/k6/core/local.(*Executor).scale
        /home/mstoykov/.gvm/pkgsets/go1.12.9/global/src/github.com/loadimpact/k6/core/local/local.go:360 +0x314

Hi @Johnny_H, would you mind giving the script you used to trigger above panic?

Thanks.

@cuonglm, here is the test script:

function ConnectWebSocket(url, params, timeout) {
   ws.connect(url, params, function (socket) {
       socket.on('open', function open() {
           console.log('websocket connected');
           socket.setInterval(function timeout() {
               socket.ping();
               console.log("Pinging every 10sec (setInterval test)");
           }, 10000);
       });

       socket.on('message', function incoming(data) {
           console.log(data);
       });
       socket.on("pong", function () {
           console.log('connection is alive');

       });
       socket.on('close', function close() {
           console.log("websocket is closed");
           sleep(10);
           console.log("will reconnect in 10 secs");
           ConnectWebSocket(url, params);
       });

       socket.on('error', function (e) {
           if (e.error() != "websocket: close sent") {
               console.log('An unexpected error occured: ', e.error());
               sleep(10);
               console.log("Exception and will reconnect in 10 secs");
               ConnectWebSocket(url, params, timeout);
           }
       });

       socket.setTimeout(function () {
           socket.close();
       }, timeout);
   })
}

Hi Johnny, what version of k6 you are using?

If you are using a stable version, would you mind trying with the master to see if the issue was fixed.

@cuonglm, I installed the latest release version [k6-v0.25.0-amd64.msi] and checked the issue with this version. It was indeed fixed. And it seemed there was another problem, once the network was available, the reconnection worked fine. However we set the timeout for the websocket connection, the websocket will be closed automatically when timeout. Once client closed the websocket, I got the following exception. Actually I am expecting to get error instead of exception and allow test to continue running.
INFO[0111] Pinging every 10sec (setInterval test) -
INFO[0113] {} -
INFO[0116] Pinging every 10sec (setInterval test) -
INFO[0121] websocket is closed -
INFO[0121] Pinging every 10sec (setInterval test)
INFO[0121] An unexpected error occured: 0=“tls: use of closed connection”
INFO[0121] the connection is not alive and try to reconnect websocket in 5 secs
INFO[0131] Connection Duration: 0=130232-
INFO[0131] Timeout: 0=-10232
INFO[0131] websocket connected -
INFO[0131] websocket is closed
INFO[0131] {“C”:“d-9E633432-B,0|Eg6,0|Eg2,0|Eg7,3”,“S”:1,“M”:[]}
INFO[0131] Pinging every 10sec (setInterval test)
ERRO[0131] TypeError: Cannot read property ‘error’ of undefined