Implement the cancellation of connection attmpe for NIO and OIO transport

- Related issue: #1432
- Also added test cases to validate the implementation