質問編集履歴

2

例外発生条件について追記

2017/08/22 03:06

投稿

tr20170808
tr20170808

スコア14

test CHANGED
File without changes
test CHANGED
@@ -137,3 +137,19 @@
137
137
  End If
138
138
 
139
139
  End Try
140
+
141
+
142
+
143
+ ###補足情報
144
+
145
+ 条件によって正常終了する場合があることがあったので追記いたします。
146
+
147
+
148
+
149
+ PHPの内容:SQLでSELECTして結果を返しています
150
+
151
+ 条件によっては例外が発生せずに正常終了しています
152
+
153
+ サーバは起動しています。NGパターンは試せていませんが、OKパターンの検索条件では正常終了しています。
154
+
155
+ 今のところほぼ全件を返すような条件だとNGで少数の結果が返るような条件だとOKというところまでしか試せておりません。

1

ソース追加

2017/08/22 03:06

投稿

tr20170808
tr20170808

スコア14

test CHANGED
@@ -1 +1 @@
1
- VB.NETで発生する「接続が切断されました: 接続が予期せずに閉じられました。」の意味を知りたい
1
+ VB.NETで発生する「接続が切断されました: 接続が予期せずに閉じられました。」の意味を知りたい
test CHANGED
@@ -31,3 +31,109 @@
31
31
  Windows10
32
32
 
33
33
  PHP5.5.9
34
+
35
+
36
+
37
+ ###該当のソースコード
38
+
39
+ '文字コードを指定する
40
+
41
+ Dim enc As System.Text.Encoding =
42
+
43
+ System.Text.Encoding.GetEncoding("shift_jis")
44
+
45
+
46
+
47
+ 'バイト型配列に変換
48
+
49
+ Dim postDataBytes As Byte() =
50
+
51
+ System.Text.Encoding.ASCII.GetBytes(postData)
52
+
53
+
54
+
55
+ Dim req As HttpWebRequest = CType(WebRequest.Create(sTargetUrl), HttpWebRequest)
56
+
57
+
58
+
59
+ ' HTTP圧縮への対応
60
+
61
+ req.AutomaticDecompression = DecompressionMethods.GZip
62
+
63
+
64
+
65
+ 'メソッドにPOSTを指定
66
+
67
+ req.Method = "POST"
68
+
69
+
70
+
71
+ 'ContentTypeを"application/x-www-form-urlencoded"にする
72
+
73
+ req.ContentType = "application/x-www-form-urlencoded"
74
+
75
+
76
+
77
+ 'POST送信するデータの長さを指定
78
+
79
+ req.ContentLength = postDataBytes.Length
80
+
81
+
82
+
83
+ 'データをPOST送信するためのStreamを取得
84
+
85
+ Using reqStream As System.IO.Stream = req.GetRequestStream()
86
+
87
+ '送信するデータを書き込む
88
+
89
+ reqStream.Write(postDataBytes, 0, postDataBytes.Length)
90
+
91
+ End Using
92
+
93
+
94
+
95
+ ' ファイルのダウンロード
96
+
97
+ Dim json As String = String.Empty
98
+
99
+ Dim res As WebResponse = Nothing
100
+
101
+ Dim st As Stream = Nothing
102
+
103
+ Dim sr As StreamReader = Nothing
104
+
105
+
106
+
107
+ Try
108
+
109
+ res = req.GetResponse() ' ← *** ここで例外が発生 ***
110
+
111
+ st = res.GetResponseStream()
112
+
113
+ sr = New StreamReader(st)
114
+
115
+ st = Nothing
116
+
117
+ json = sr.ReadToEnd()
118
+
119
+ Finally
120
+
121
+ If sr IsNot Nothing Then
122
+
123
+ sr.Close()
124
+
125
+ End If
126
+
127
+ If st IsNot Nothing Then
128
+
129
+ st.Close()
130
+
131
+ End If
132
+
133
+ If res IsNot Nothing Then
134
+
135
+ res.Close()
136
+
137
+ End If
138
+
139
+ End Try