The request was aborted: Could not create SSL/TLS secure channel

I have got this exception (The request was aborted: Could not create SSL/TLS secure channel) While sending new order . By calling this api :

PlaceOrder(string Exchange, string TradingSymbol, string TransactionType, int Quantity, decimal? Price = null, string Product = null, string OrderType = null, string Validity = null, int? DisclosedQuantity = null, decimal? TriggerPrice = null, decimal? SquareOffValue = null, decimal? StoplossValue = null, decimal? TrailingStoploss = null, string Variety = "regular", string Tag = "");

Can you please tell me why i got this exception . But in next order everything got working fine .
  • sujith
    Can you run with debug logs enabled and paste the complete stacktrace here?
    Make sure to mention what version of the library you are using and remove all app and client specific tokens.
  • vikas_kite
    This is very random . It is not coming frequently . I have using this API since one year . But i got this issue today for the first time .

    I am writing the stack trace log here .

    The request was aborted: Could not create SSL/TLS secure channel.
    at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)
    at System.Net.HttpWebRequest.GetRequestStream()
    at KiteConnect.Kite.Request(String Route, String Method, Object Params, Boolean json)
    at KiteConnect.Kite.Post(String Route, Object Params, Boolean json)
    at KiteConnect.Kite.PlaceOrder(String Exchange, String TradingSymbol, String TransactionType, Int32 Quantity, Nullable`1 Price, String Product, String OrderType, String Validity, Nullable`1 DisclosedQuantity, Nullable`1 TriggerPrice, Nullable`1 SquareOffValue, Nullable`1 StoplossValue, Nullable`1 TrailingStoploss, String Variety, String Tag)
    at ZDH_Order.Controller.SessionHandling.PlaceOrder(OMS_Order obj)
  • tonystark
    Looks like a network issue or firewall block. Do you have everything upto date - KiteConnect library/Windows updates etc?
  • vikas_kite
    vikas_kite edited March 2023
    But why is it coming randomly in between of market hour ? It is not coming on placing every order .
    If there if firewall block then it should come for the every order , right ?
    Recently i have formatted my machine after that this issue started to happen.

    I have other set up also running on different server but running smoothly there .
  • tonystark
    If there if firewall block then it should come for the every order , right ?
    Depends on how firewall identifies a connection as malicious or not. If you have a firewall it is better to whitelist your application.
    Recently i have formatted my machine after this it started coming for the same server only
    Could you clarify this? You recently formatted and then this issue started to happen? Or you tried formatting after this issue started to happen and it is still not fixed?
  • vikas_kite
    Could you clarify this? You recently formatted and then this issue started to happen? Yes
  • vikas_kite
    One more thing to add on :
    As i cheeked firewall is off on the machine .
    There is no network monitoring happen on antivirus also . It is also off
  • tonystark
    In that case I'm out of ideas. Since this happened after a OS reset and your systems work fine in another machine this is clearly a device configuration issue. And that is out of scope of this forum.

    You could try a different ISP, different network device (switch to WiFi/LAN/Android USB tethering), different DNS (OpenDNS, Cloudflare, Google DNS), a VPN (Cloudflare WARP), a different version of your OS etc.

    If you are able to pinpoint to particular configuration or if you are able to identify certain patterns (like disconnection happens precisely at certain times, or after certain number of requests, or after certain action like cancelling an order) let us know, we will investigate further.
  • vikas_kite
    Actually we are not placing order frequently . This issue is coming when order is being placed after some ideal time (30 minutes approx ) . Whenever order transaction is inactive for the 20~30 minutes then it comes right after the new is placed .

    Is it helpful ?
  • tonystark
    Are there any other API calls during this 20 min period? Or you only make order place calls?
  • vikas_kite
    only order place calls .
  • vikas_kite
    Is there any built in heartbeat / keep alive message sending mechanism from kite api to kite platform ? SO that i can check may be antivirus or anything blocking that message . But I have white list the application and it's connection at antivirus and disable the firewall as well .
    Why it is coming after waiting for some ideal time .
  • tonystark
    There is no heart beat mechanism for APIs.

    The "ideal time" is what your OS network stack/firewall/servers agree on how much time has been in idle state and decides to free up resources by disconnecting the connection. This is normal in every internet connected services. And if the API clients are not in a unobstructed environment, clients can handle such disconnections by catching the exception and retrying one more time.
  • vikas_kite
    It is coming on only order place . Is there any way to know this exception before sending any order ?
  • tonystark
    "Exception" is as the word describes something that is happening out of the ordinary. It is thrown when it happens. There is no way to catch it before it happens.

    You can catch the exception, check if the error is SSL/TLS related, then retry the order again.
  • vikas_kite
    I can do this but .. Why it was working earlier . I have another set up it is working fine . I am looking at my end at OS level . Please let me know you also get anything to suggest any solution . It will be great help for me .Thanks in advance . I am struggling with this issue since 20 days .
  • abv_078
    I use Howutrade's api for order slicing. When placing orders > freeze quantity, sometimes I get partial fills and remaining orders are rejected with this SSL/TSL error. Can anybody explain this? I use windows laptop with firewall turned off but still get this error occasionally. Also, if I deploy the algo in AWS mumbai server, will it help?
Sign In or Register to comment.