Shuffle gateway logic around for improved reconnecting.
Shuffle gateway logic around for improved reconnecting.

Fixes #957

MjAbuz/fabric,rane-hs/fabric-py3,askulkarni2/fabric,tolbkni/fabric,fernandezcuesta/fabric,elijah513/fabric,mathiasertl/fabric,pgroudas/fabric,StackStorm/fabric,tekapo/fabric,cgvarela/fabric,opavader/fabric,rbramwell/fabric,haridsv/fabric,pashinin/fabric,kxxoling/fabric,cmattoon/fabric,jaraco/fabric,xLegoz/fabric,rodrigc/fabric,TarasRudnyk/fabric,raimon49/fabric,amaniak/fabric,kmonsoor/fabric,sdelements/fabric,bitprophet/fabric,ploxiln/fabric,hrubi/fabric,likesxuqiang/fabric,bspink/fabric,qinrong/fabric,bitmonk/fabric,SamuelMarks/fabric,itoed/fabric