They may be distantly related, but it cannot be known for certain. From etymonline.com:
1400, "tube for projectiles," from O.Fr. canon (14c.), from It. cannone "large tube," augmentive of L. canna "reed, tube" (see cane). ... Spelling not differentiated from canon till c.1800.
And Latin canna is from Greek kanna, "reed".
"church law," O.E., from L.L. canon, in classical L.,
"measuring line, rule," from Gk. kanon "any straight rod or bar; rule;
standard of excellence," perhaps from [Greek] kanna "reed" (see cane). Taken
in ecclesiastical sense for "decree of the Church," and as such passed
through L.L. to O.E.
So cannon derived from Greek kanna "reed" (both are hollow tubes), and canon may have derived from Greek kanna "reed" (both are straight rules).
Even if these words are not connected, Anatoly Liberman's Word Origins And How We Know Them: Etymology for Everyone explains many other similar can- words are connected: cane as a walking stick, as a cane chair and as cane sugar are from a "hollow stem", from Latin canna "reed, cane, tube, pipe". Can "pot" via Latin canna "vessel", canal and channel are "pipes" via French, as is canyon a "pipe" but via Spanish. The Italian canellone and cannoli are "small tubes".