Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

socket closed when switching to null safety #171

Closed
close2 opened this issue Mar 28, 2021 · 1 comment
Closed

socket closed when switching to null safety #171

close2 opened this issue Mar 28, 2021 · 1 comment
Labels

Comments

@close2
Copy link
Collaborator

close2 commented Mar 28, 2021

Hello,

I ran into this error today when migrating to null safety. I'm on Windows 10 Pro using mailer 4.0.0. The code sends an email when I'm on sdk: '>=2.10.0 <3.0.0'. However, as soon as I switch to sdk: '>=2.12.0 <3.0.0' I get the Socket was closed even though a response was expected error.

Note, it just so happened that my code didn't require any null safety annotations during migration, so it's running the exact same code and the only difference is the sdk upgrade to 2.12.0. It's the strangest thing!

Dart version: Dart SDK version: 2.12.2 (stable) (Wed Mar 17 10:30:20 2021 +0100) on "windows_x64"

Here's my code:

Future<void> sendEmail(String subjectText, String messageText) async {
  var mailgunServer = mailgun(
      'postmaster@sandbox_____.mailgun.org',
      '____');

  var message = Message()
    ..from = Address('[email protected]', '___')
    ..recipients.add(
        '[email protected]') 
    ..subject = subjectText
    ..text = messageText;

  var sendFuture = send(message, mailgunServer)
      .then((_) => print('email sent!'))
      .catchError((e) => print('Error: $e'));

  return sendFuture;
}

Here's the log when it works on sdk 2.10.0:

FINER: 2021-03-19 16:33:19.258843: Connecting to smtp.mailgun.org at port 587.
FINE: 2021-03-19 16:33:19.352492: >
FINE: 2021-03-19 16:33:19.378829: < 220 Mailgun Influx ready
FINE: 2021-03-19 16:33:19.382727: > EHLO ________
FINE: 2021-03-19 16:33:19.412950: < 250 smtp-out-n07.prod.us-west-2.postgun.com
< 250 AUTH PLAIN LOGIN
< 250 SIZE 52428800
< 250 8BITMIME
< 250 SMTPUTF8
< 250 PIPELINING
< 250 STARTTLS
FINE: 2021-03-19 16:33:19.414913: > STARTTLS
FINE: 2021-03-19 16:33:19.452953: < 220 Go ahead
FINE: 2021-03-19 16:33:19.541710: > EHLO __________
FINE: 2021-03-19 16:33:19.570976: < 250 smtp-out-n07.prod.us-west-2.postgun.com
< 250 AUTH PLAIN LOGIN
< 250 SIZE 52428800
< 250 8BITMIME
< 250 SMTPUTF8
< 250 PIPELINING
FINE: 2021-03-19 16:33:19.572924: > AUTH LOGIN
FINE: 2021-03-19 16:33:19.600218: < 334 ____________
FINE: 2021-03-19 16:33:19.603157: > _________________
FINE: 2021-03-19 16:33:19.629493: < _______________
FINE: 2021-03-19 16:33:19.633381: > _________________
FINE: 2021-03-19 16:33:19.680206: < 235 Authentication successful
FINE: 2021-03-19 16:33:19.682163: > MAIL FROM:<[email protected]> SMTPUTF8
FINE: 2021-03-19 16:33:19.707519: < 250 Sender address accepted
FINE: 2021-03-19 16:33:19.709459: > RCPT TO:<[email protected]>
FINE: 2021-03-19 16:33:19.733843: < 250 Recipient address accepted
FINE: 2021-03-19 16:33:19.734818: > DATA
FINE: 2021-03-19 16:33:20.031346: < 354 Continue
FINE: 2021-03-19 16:33:20.059614: > .
FINE: 2021-03-19 16:33:20.159115: < 250 Great success
FINE: 2021-03-19 16:33:20.160075: > QUIT
email sent!

And here's the log when it fails on sdk 2.12.0:

FINER: 2021-03-19 16:34:38.333559: Connecting to smtp.mailgun.org at port 587.
FINE: 2021-03-19 16:34:38.424279: >
FINE: 2021-03-19 16:34:38.451590: < 220 Mailgun Influx ready
FINE: 2021-03-19 16:34:38.455478: > EHLO ____________
FINE: 2021-03-19 16:34:38.485716: < 250 smtp-out-n01.prod.us-west-2.postgun.com
< 250 AUTH PLAIN LOGIN
< 250 SIZE 52428800
< 250 8BITMIME
< 250 SMTPUTF8
< 250 PIPELINING
< 250 STARTTLS
FINE: 2021-03-19 16:34:38.487679: > STARTTLS
FINE: 2021-03-19 16:34:38.521804: < 220 Go ahead
FINE: 2021-03-19 16:34:38.618377: > EHLO ______________
FINE: 2021-03-19 16:34:38.649594: < 250 smtp-out-n01.prod.us-west-2.postgun.com
< 250 AUTH PLAIN LOGIN
< 250 SIZE 52428800
< 250 8BITMIME
< 250 SMTPUTF8
< 250 PIPELINING
FINE: 2021-03-19 16:34:38.652501: > AUTH LOGIN
FINE: 2021-03-19 16:34:38.680788: < 334 ______________
FINE: 2021-03-19 16:34:38.686652: > _______________________
FINE: 2021-03-19 16:34:38.714925: < 334 _________________
FINE: 2021-03-19 16:34:38.717850: > _____________________
FINE: 2021-03-19 16:34:38.745160: < 235 Authentication successful
FINE: 2021-03-19 16:34:38.751988: > MAIL FROM:<[email protected]> SMTPUTF8
FINE: 2021-03-19 16:34:38.776373: < 250 Sender address accepted
FINE: 2021-03-19 16:34:38.787101: > RCPT TO:<[email protected]>
FINE: 2021-03-19 16:34:38.813436: < 250 Recipient address accepted
FINE: 2021-03-19 16:34:38.819289: > DATA
FINE: 2021-03-19 16:34:38.847586: < 354 Continue
FINE: 2021-03-19 16:34:38.859278: > .
WARNING: 2021-03-19 16:34:38.863179: Could not send mail.
Error: Socket was closed even though a response was expected.

Originally posted by @OlegAlexander in #106 (comment)

@close2 close2 added the bug label Mar 28, 2021
@close2
Copy link
Collaborator Author

close2 commented Mar 28, 2021

I can reproduce this bug.

Working on a fix.

close2 added a commit that referenced this issue Mar 31, 2021
fixes issue #172
fixes issue #171
fixes issue #167
fixes issue #152

improved document for cid (issue #104)
close2 added a commit that referenced this issue Mar 31, 2021
fixes issue #172
fixes issue #171
fixes issue #167
fixes issue #152

improved document for cid (issue #104)
close2 added a commit that referenced this issue Mar 31, 2021
fixes issue #172
fixes issue #171
fixes issue #167
fixes issue #152

improved document for cid (issue #104)
@close2 close2 closed this as completed Mar 31, 2021
fsw pushed a commit to fsw/mailer that referenced this issue Nov 16, 2023
fixes issue kaisellgren#172
fixes issue kaisellgren#171
fixes issue kaisellgren#167
fixes issue kaisellgren#152

improved document for cid (issue kaisellgren#104)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant