Restrict connection to move out from nodes

In my current canvas I am able to drag a connection out from the ports. I want to restrict this behaviour.Please help

Here the connection was connected to the green ports. I dragged it outside the port. I want to restrict this behaviour

By “connection” do you mean a Link?

Are your links draggable? If so are you saying you do not want that behavior?

You can disable draggable links by not setting these properties, which you must have copied from the Draggable Links sample initialization of the Diagram:

            "draggingTool.dragsLink": true,

            "linkingTool.isUnconnectedLinkValid": true,
            "linkingTool.portGravity": 20,
            "relinkingTool.isUnconnectedLinkValid": true,
            "relinkingTool.portGravity": 20,

As you can see in nearly every other sample, by default links are not draggable on their own.