Patent Publication Number: US-2021168212-A1

Title: Communication device and non-transitory computer-readable medium storing computer-readable instructions for communication device

Description:
CROSS-REFERENCE TO RELATED APPLICATION 
     This application claims priority to Japanese Patent Application No. 2019-217164 filed on Nov. 29, 2019, the contents of which are hereby incorporated by reference into the present application. 
     TECHNICAL FIELD 
     The disclosure herein discloses art related to a communication device configured to establish a session with a server. 
     DESCRIPTION OF RELATED ART 
     An MFP configured to establish a session with a server is known. The MFP periodically sends a packet to the server after the session has been established. In a case where the session is maintained, the MFP receives a response to the packet from the server. The MFP adjusts a time interval for sending the packet to a time interval within a session timeout period defined by a firewall function of a router. 
     SUMMARY 
     A proxy server may intermediate between an MFP and a server. The technique described above does not give any consideration to a proxy server. 
     The disclosure herein provides art for suitably executing a communication confirmation with a target server with consideration given to whether a proxy server is present or not. 
     A communication device disclosed herein may comprise: a communication interface; and a controller. The controller may be configured to: establish a session according to Hypertext Transfer Protocol (HTTP) with a target server on the Internet via the communication interface; execute a communication confirmation repeatedly via the communication interface after the session has been established, the communication confirmation including that the communication device sends a confirmation signal to the target server and receives a response signal from the target server; and adjust a waiting time, the waiting time being a time period from when the target server received the confirmation signal from the communication device to when the target server sends the response signal to the communication device, in a case where a proxy server is used in communication between the communication device and the target server, the controller adjusts the waiting time by instructing the target server to use a first time as the waiting time, and in a case where the proxy server is not used in communication between the communication device and the target server, the controller adjusts the waiting time by instructing the target server to use a second time as the waiting time, the second time being longer than the first time. 
     A control method implemented by the communication device, a computer program for the communication device, and a non-transitory computer-readable medium storing computer-readable instructions for the communication device are also novel and useful. 
    
    
     
       BRIEF DESCRIPTION OF THE DRAWINGS 
         FIG. 1  shows a configuration of a communication system; 
         FIG. 2  shows a sequence diagram of a process according to a comparative example; 
         FIG. 3  shows a flowchart of a process executed by a printer according to a first embodiment; 
         FIG. 4  shows Case A1 in which a proxy server is not used; 
         FIG. 5  shows Case A2 in which a proxy server is used; 
         FIG. 6  shows a flowchart of a process executed by the printer according to a second embodiment; 
         FIG. 7  shows Case B in which a proxy server is used; and 
         FIG. 8  shows a continuation of  FIG. 7 . 
     
    
    
     EMBODIMENTS 
     First Embodiment 
     (Configuration of Communication System  2 ;  FIG. 1 ) 
     As shown in  FIG. 1 , a communication system  2  includes a printer  10 , a service providing server  100 , and a proxy server  200 . Hereinbelow, the service providing server will be termed “SP server”. 
     The printer  10  and the proxy server  200  are connected to a Local Area Network (LAN)  4 . The proxy server  200  is connected to the Internet  8 . The SP server  100  is also connected to the Internet  8 . The printer  10  is capable of communicating with the SP server  100  through the proxy server  200  and the Internet  8 . 
     The proxy server  200  is installed on the LAN  4  by an administrator of the LAN  4 . The proxy server  200  is configured to intermediate communication between devices belonging to the LAN  4  (e.g., the printer  10 ) and the Internet  8 . The printer  10  is capable of communicating with a device on the Internet  8  (e.g., the SP server  100 ), for example, by using a simple router instead of using the proxy server  200 . Advantages of using the proxy server  200  are as follows. For example, when a device on the internet  8  is communicating with a device on the LAN  4  (e.g., the printer  10 ) via the proxy server  200 , the device on the Internet  8  cannot identify which one of devices on the LAN  4  it is communicating with. As such, anonymity of the device on the LAN  4  is ensured in a perspective from the device on the Internet  8 . Further, the proxy server  200  caches information related to the Internet  8 , which enables high-speed communication when the devices on the LAN  4  execute communication through the Internet  8 . 
     The SP server  100  is a server for providing a service related to the printer  10  to a user of the printer  10 . To provide the service to the user, the SP server  100  is configured to send, to the printer  10 , an information request for requesting state information indicating an operating state of the printer  10  and receive the state information from the printer  10  by using an HTTP session to be described later. Further, the SP server  100  is configured to execute a process for providing the service by using the received state information. The service may, for example, be a shipping service of shipping a cartridge. In this case, the state information includes remaining amount information indicating a remaining amount in an ink cartridge in the printer  10 . For example, in a case of determining that the remaining amount indicated by the remaining amount information received from the printer  10  is equal to or less than a predetermined threshold, the SP server  100  may execute a shipping process (e.g., notification to a worker) for shipping a new cartridge to be attached to the printer  10 . In another example, the service may be a service of leasing the printer  10  to the user with charges calculated based on usage of the printer  10  (e.g., the number of printed sheets), a service of providing maintenance of the printer  10  to the user, a service of providing email print which is printing that uses an email, or the like. Here, in case of the email print, when receiving an email including image data from outside, the SP server  100  sends a notification indicating that the email has been received to the printer  10  by using the HTTP session to be described later. Then, in a case of receiving a response to the notification from the printer  10 , the SP server  100  sends the image data in the email to the printer  10 . The printer  10  then executes printing according to the image data, and the email print is thereby realized. 
     (Configuration of Printer  10 ) 
     The printer  10  is a device with a print function. The printer  10  includes a LAN interface  12  and a controller  30 . The respective units  12  and  30  are connected to a bus line (reference sign omitted). Hereinbelow, an interface will be denoted “UP”. The LAN I/F  12  is an I/F for executing communication through the LAN  4  and is connected to the LAN  4 . The controller  30  includes a CPU  32  and a memory  34 . The CPU  32  is configured to execute various processes according to a program  40  stored in the memory  34 . The memory  34  is configured of a volatile memory, a nonvolatile memory, and the like. The memory  34  further stores connection information  42  and proxy setting information  44 . 
     The connection information  42  is information for establishing an HTTP session according to Hypertext Transfer Protocol (HTTP) between the SP server  100  on the Internet  8  and the printer  10 . The HTTP session is a session that enables so-called full-time communication. Once established, the HTTP session is maintained until the printer  10  is turned off. By using the HTTP session, the SP server  100  can send a request (e.g., the information request mentioned above) to the printer  10  over the firewall of the LAN  4  to which the printer  10  belongs, without receiving a request from the printer  10 . The HTTP session may, for example, be a session according to an eXtensible Messaging and Presence Protocol (XMPP) over Bidirectional-streams Over Synchronous HTTP (BOSH). The HTTP session is not limited to the session according to the XMPP over BOSH, but may be a session according to another protocol complying with the HTTP (e.g., WebSocket). 
     The connection information  42  includes authentication information (e.g., an access token) for authenticating the printer  10 . The connection information  42  is created by the SP server  100 . For example, when an instruction for starting the service is inputted to the printer  10 , the connection information  42  is sent from the SP server  100  to the printer  10  and is stored in the memory  34  of the printer  10 . Then, the printer  10  executes communication with the SP server  100  by using the connection information  42  in the memory  34 . As a result, the printer  10  is authenticated by the SP server  100 , and an HTTP session is established between the printer  10  and the SP server  100 . 
     The proxy setting information  44  indicates one of a value “ON” indicating that the proxy server  200  is to be used and a value “OFF” indicating that the proxy server  200  is not to be used. The proxy setting information  44  indicates “OFF” by default. The proxy setting information  44  is inputted by the user. For example, in a case where “ON” is inputted as the proxy setting information  44 , an address of the proxy server  200  and a port number to be used for communication with the proxy server  200  are inputted. 
     (Comparative Example;  FIG. 2 ) 
     Before explanation of processes according to the embodiment, a process according to a comparative example will be described with reference to  FIG. 2 . A printer  900  of the comparative example is similar to the printer  10  of the embodiment except that a program different from the program  40  is stored in its memory  34 . In an initial state of  FIG. 2 , the proxy setting information  44  of the printer  900  indicates “ON”. 
     In a case where an instruction for starting the service is inputted in the printer  900 , the printer  900  receives the connection information  42  (e.g., an access token) from the SP server  100  and stores this connection information  42  in the memory  34  in T 10 . It should be noted that if the printer  900  is to be establish an HTTP session again after an HTTP session in T 20 A, T 20 B described later has established and this HTTP session has disconnected, the printer  900  establishes the HTTP session by using the connection information  42  in the memory  34  without receiving the connection information  42  again from the SP server  100 . 
     In T 20 A and T 20 B, the printer  900  establishes an HTTP session with the SP server  100  via the proxy server  200  by using the connection information  42  in the memory  34 . Specifically, an HTTP session is established between the printer  900  and the proxy server  200  and an HTTP session is also established between the proxy server  200  and the SP server  100 . Through the HTTP session, a communication confirmation for checking on presence of a communication disturbance is repeatedly executed. The communication confirmation includes one of the devices (e.g., printer  900 ) on the HTTP session sending a Keep Alive signal to the other device (e.g., the SP server  100 ) on the HTTP session and the one of the devices receiving a response to the Keep Alive signal (hereinbelow termed “Keep Alive response”) from the other device. For example, in the printer  900 , a timeout period (e.g., “5 minutes”) is set for communication according to Transmission Control Protocol (TCP). Here, “timeout” is a so-called TCP timeout. The TCP timeout period is a duration of time during which establishment of a session according to the TCP can be maintained. In general, in a case where a session according to the TCP has been established but the TCP timeout period elapses from when the session was established without one of the devices receiving any signal from the other of the devices, this session is disconnected. In a case where the Keep Alive response is received before the timeout period elapses from when the Keep Alive signal was sent, it is determined that no communication disturbance is occurring and the communication confirmation succeeds. On the other hand, in a case where the Keep Alive response is not received before the timeout period elapses from when the Keep Alive signal was sent, it is determined that a communication disturbance is occurring and the communication confirmation fails. In the case where the communication confirmation fails, the HTTP session is disconnected. When the HTTP session is disconnected, the printer  900  attempts to establish an HTTP session again with the SP server  100 . 
     In an HTTP session, Negotiation is executed. The Negotiation is for adjusting a waiting time that is a time period from when one of devices, which is a recipient of a Keep Alive signal, received a Keep Alive signal to when this one device sends a Keep Alive response. The Negotiation includes the other of the devices, which is a sender of the Keep Alive signal, instructing the one device to use a certain waiting time. 
     In this comparative example, after having established the HTTP session with the SP server  100  in T 20 A and T 20 B, the printer  900  executes Negotiation with the SP server  100  in T 22 A to T 26 B. This Negotiation includes the printer  900  instructing the SP server  100  to use a waiting time “3 minutes”. Specifically, the printer  900  sends a Negotiation signal including the waiting time “3 minutes” to the proxy server  200  in T 22 A, and then the proxy server  200  sends this Negotiation signal to the SP server  100  in T 22 B. The Negotiation signal is a signal for instructing the SP server  100  to use a certain waiting time. In T 24 , the SP server  100  determines the waiting time as “3 minutes” according to the Negotiation signal. Then, the SP server  100  sends a Negotiation response including the determined waiting time “3 minutes” to the proxy server  200  in T 26 A, and then the proxy server  200  sends this Negotiation response to the printer  900  in T 26 B. The Negotiation response is a response to the Negotiation signal. 
     After having executed the Negotiation with the SP server  100 , the printer  900  starts sending a Keep Alive signal to the SP server  100 . Since the proxy setting information  44  of the printer  900  indicates “ON” in this comparative example, the printer  900  sends the Keep Alive signal to the proxy server  200  via the LAN  4  in T 30 A. 
     When receiving the Keep Alive signal from the printer  900  in T 30 A, the proxy server  200  sends the Keep Alive signal to the SP server  100  in T 30 B. 
     The SP server  100  receives the Keep Alive signal from the proxy server  200  in T 30 B via the Internet  8 . Then, after the waiting time “3 minutes” has elapsed from the receipt of the Keep Alive signal, the SP server  100  sends a Keep Alive response to the proxy server  200  via the Internet  8  in T 32 A. 
     As described above, the proxy server  200  has various functions as compared to a simple router. Therefore, due to an influence of processing time in the proxy server  200 , it is highly possible that a timing when the SP server  100  receives a Keep Alive signal with use of the proxy server  200  is delayed as compared to a timing when the SP server  100  receives a Keep Alive signal without use of the proxy server  200 . In the present comparative example, the timing of T 32 A when the proxy server  200  receives the Keep Alive response from the SP server  100  is within a lapse of a timeout period “5 minutes” from when the printer  900  sent the Keep Alive signal in T 30 A. However, as a result of the delay in the Keep Alive signal, the proxy server  200  cannot send the Keep Alive response to the printer  900  before the timeout period “5 minutes” elapses. Due to this, the communication confirmation fails. As a result, the HTTP session is disconnected. 
     In the case where the proxy server  200  is used as above, a Keep Alive signal or a Keep Alive response could be delayed. In such a case, the communication confirmation fails due to the timeout period having elapsed, despite no communication disturbance occurring between the printer  900  and the SP server  100 . That is, the HTTP session could be unnecessarily disconnected, despite no communication disturbance occurring. Meanwhile, the present embodiment realizes suitable execution of the communication confirmation with consideration given to whether the proxy server  200  intermediates or not (i.e., whether the proxy server  200  is used or not) between the devices on an HTTP session. 
     (Process by Printer;  FIG. 3 ) 
     A process executed by the printer  10  of the present embodiment will be described with reference to  FIG. 3 . The process of  FIG. 3  is initiated with one of the following as a trigger: the printer  10  storing the connection information  42  in the memory  34  (i.e., the instruction for starting the service is inputted); the printer  10  being turned on with the connection information  42  stored in the memory  34 ; and an operation of changing the proxy setting information  44  being performed by the user. The process of  FIG. 3  is terminated when the printer  10  is turned off. 
     In S 10 , the CPU  32  determines whether the trigger of the process of  FIG. 3  is a specific trigger. Here, the specific trigger is one of the printer  10  storing the connection information  42  in the memory  34  and the operation of changing the proxy setting information  44  being performed by the user. In a case of determining that the trigger of the process of  FIG. 3  is the specific trigger (YES in S 10 ), the CPU  32  proceeds to S 20 . 
     In S 20 , the CPU  32  determines whether the current proxy setting information  44  is “ON”. In a case of determining that the current proxy setting information  44  is “ON” (YES in S 20 ), the CPU  32  determines in S 22  that the SP server  100  is to be instructed to use a first time (e.g., “1 minute”) as the waiting time to in Negotiation. Then, the CPU  32  stores the first time in the memory  34  as a stored value of S 30  (to be described later). 
     In a case of determining that the current proxy setting information  44  is “OFF” (NO in S 20 ), the CPU  32  determines in S 24  that the SP server  100  is to be instructed to use a second time (e.g., “3 minutes”), which is longer than the aforementioned first time, as the waiting time. Then, the CPU  32  stores the second time in the memory  34  as a stored value of S 30  (to be described later). 
     In a case where the trigger of the process of  FIG. 3  is not the specific trigger, that is, in a case where the CPU  32  determines that the trigger of  FIG. 3  is the printer  10  being turned on with the connection information  42  stored in the memory  34  (NO in S 10 ), the CPU  32  determines the stored value as the waiting time in S 30 . When any one of the processes of S 22 , S 24 , and S 30  is completed, a process of S 40  is executed. 
     In S 40 , the CPU  32  establishes an HTTP session with the SP server  100  via the LAN I/F  12  by using the connection information  42  in the memory  34 , and then the CPU  32  executes Negotiation with the SP server  100 . This Negotiation includes instructing the SP server  100  to use the waiting time determined by one of the processes of S 22 , S 24 , and S 30 . 
     In S 42 , the CPU  32  sends a Keep Alive signal to the SP server  100  via the LAN I/F  12 . 
     In S 44 , the CPU  32  determines whether the sending of the Keep Alive signal succeeded. For example, in a case where the CPU  32  can receive a receipt notification indicating that the Keep Alive signal was received from an intermediating device (e.g., the proxy server  200 , a simple router, etc.) that intermediates communication between the LAN  4  and the Internet  8 , the CPU  32  determines that the sending of the Keep Alive signal succeeded. On the other hand, in a case where the CPU  32  cannot receive the receipt notification from the intermediating device, for example, due to the intermediating device being off, the CPU  32  determines that the sending of the Keep Alive signal failed. The CPU  32  proceeds to S 46  in a case of determining that the sending of the Keep Alive signal succeeded (YES in S 44 ), while the CPU  32  returns to S 40  in a case of determining that the sending of the Keep Alive signal failed (NO in S 44 ). In the case where the sending of the Keep Alive signal failed, the HTTP session was disconnected due to the intermediating device being off, thus the CPU  32  attempts to establish an HTTP session again in S 40 . 
     In S 46 , the CPU  32  determines whether a Keep Alive response to the Keep Alive signal of S 42  is received from the SP server  100  via the LAN I/F  12 . For example, in a case of receiving a Keep Alive response from the SP server  100  before a timeout period (e.g., “5 minutes”) elapses from the sending of the Keep Alive signal in S 42 , the CPU  32  determines YES in S 46  and proceeds to S 42 , and sends a Keep Alive signal again to the SP server  100 . On the other hand, in a case of not receiving a Keep Alive response from the SP server  100  (e.g., in a case where the timeout period has elapsed from the sending of the Keep Alive signal in S 42  without a Keep Alive response being received from the SP server  100  or in a case where a signal different from a Keep Alive response is received from the SP server  100  before the timeout period elapses), the CPU  32  determines NO in S 46  and returns to S 40 . In the case of NO in S 46 , the HTTP session is disconnected due to the failure of the communication confirmation, thus the CPU  32  attempts to establish an HTTP session again in S 40 . 
     (Case A1 in which Proxy Server is Not Used;  FIG. 4 ) 
     A specific Case A1 realized by the process of  FIG. 3  will be described with reference to  FIG. 4 . In Case A1, the proxy server is not used. In an initial state of  FIG. 4 , the proxy setting information  44  indicates “OFF”. Hereinbelow, for easier understanding, processes executed by CPUs of respective devices (e.g., the CPU  32  of the printer  10 ) will be described with the respective devices (e.g., the printer  10 ) as the subject of action instead of describing the processes with the CPUs as the subject of action. Further, hereinbelow, communication executed between the printer  10  and the SP server  100  is via the LAN  4  and the Internet  8 . Thus, the phrases “via the LAN  4 ” and “via the Internet  8 ” will be omitted unless otherwise mentioned. 
     When the instruction to start the service is inputted, the printer  10  receives the connection information  42  form the SP server  100  and stores this connection information  42  in the memory  34  in T 100  (YES in S 10  of  FIG. 3 ). 
     In T 102 , the printer  10  determines that the current proxy setting information  44  is “OFF” (NO in S 20 ). Then, in T 110 , the printer  10  determines the second time “3 minutes” as the waiting time (S 24 ). 
     In T 120 , the printer  10  establishes an HTTP session with the SP server  100  by using the connection information  42  in the memory  34  (S 40 ). 
     In T 122 , the printer  10  sends a Negotiation signal including the waiting time “ 3  minutes” to the SP server  100  (S 40 ). Due to this, the SP server  100  determines the waiting time as “3 minutes” according to the Negotiation signal in T 124 . Then, the SP server  100  sends a Negotiation response including the determined waiting time “3 minutes” to the printer  10  in T 126 . 
     Next, the printer  10  sends a Keep Alive signal to the SP server  100  in T 130  (S 42 ). In the present case, an intermediating device (e.g., a simple router, not shown) between the printer  10  and the SP server  100  operates normally. Thus, the Keep Alive signal is successfully sent (YES in S 44 ), and the SP server  100  receives the Keep Alive signal from the printer  10  in T 130 . 
     After the waiting time “3 minutes” has elapsed from the receipt of the Keep Alive signal, the SP server  100  sends a Keep Alive response to the printer  10  in T 132 . Since the simple router, for example, is used but the proxy server  200  is not used in the present case, the Keep Alive signal or the Keep Alive response is less likely to be delayed. Therefore, the printer  10  receives the Keep Alive response from the SP server  100  before the timeout period of “ 5  minutes” elapses. 
     The printer  10  determines in T 132  that the Keep Alive response is received from the SP server  100  (YES in S 46 ) and sends a Keep Alive signal again to the SP server  100  in T 150 . T 152  is similar to T 132 . That is, the printer  10  repeatedly executes the communication confirmation and each communication confirmation succeeds. 
     In the present case in which the proxy server  200  is not used, the waiting time is adjusted to the second time “3 minutes”, which is relatively long. The Keep Alive signals or the Keep Alive responses are less likely to be delayed in the case where the proxy server  200  is not used, as compared to a case in which the proxy server  200  is used. By adjusting the waiting time to a longer time, the number of times the communication confirmation is executed within a predetermined time period (e.g., one day) can be reduced. 
     (Case A2 in which Proxy Server is Used;  FIG. 5 ) 
     A specific Case A2 realized by the process of  FIG. 3  will be described with reference to  FIG. 5 . In Case A2, the proxy server is used. Case A2 is a continuation of Case A1. 
     In T 200 , the printer  10  changes the proxy setting information  44  from “OFF” to “ON” in response to the operation of changing the proxy setting information  44  being performed by the user. Here, when the proxy setting information  44  is changed, the HTTP session is disconnected. 
     In T 204 , the printer  10  determines that the current proxy setting information  44  is “ON” (YES in S 20 ). Then, in T 210 , the printer  10  determines the first time of “1 minute” as the waiting time (S 22 ). 
     In T 220 , the printer  10  establishes an HTTP session again with the SP server  100  via the proxy server  200  by using the connection information  42  in the memory  34  (S 40 ). 
     In T 222 , the printer  10  sends a Negotiation signal including the waiting time “1 minute” to the SP server  100  via the proxy server  200  (S 40 ). Due to this, the SP server  100  determines the waiting time as “1 minute” according to the Negotiation signal in T 224 . Then, the SP server  100  sends a Negotiation response including the determined waiting time “1 minute” to the printer  10  via the proxy server  200  in T 226 . 
     Next, in T 230 A, the printer  10  sends a Keep Alive signal to the proxy server  200 . Due to this, the proxy server  200  sends the Keep Alive signal to the SP server  100  in T 230 B. 
     In T 230 B, the SP server  100  receives the Keep Alive signal from the proxy server  200 . Then, after the waiting time “1 minute” has elapsed from the receipt of the Keep Alive signal, the SP server  100  sends a Keep Alive response to the proxy server  200  via the Internet  8  in T 232 A. 
     The waiting time “1 minute” in the present case is shorter than the waiting time “ 3  minutes” in the comparative example of  FIG. 2 . Thus, in T 232 A, the proxy server  200  receives the Keep Alive response from the SP server  100  before the timeout period “5minutes” elapses, and then the printer  10  receives in T 232 B the Keep Alive response from the proxy server  200  before the timeout period “5minutes” elapses. That is, the communication confirmation succeeds. 
     The printer  10  determines that the Keep Alive response is received from the SP server  100  in T 232 B (YES in S 46 ), and sends a Keep Alive signal again to the proxy server  200  in T 250 A. T 250 B to T 252 B are similar to T 230 B to T 232 B. That is, the printer  10  repeatedly executes the communication confirmation and each communication confirmation succeeds. 
     In the present case in which the proxy server  200  is used, the waiting time is adjusted to the first time of “1 minute”, which is relatively short. As described in the comparative example of  FIG. 2 , it is highly possible that Keep Alive signal or Keep Alive response is delayed in the case where the proxy server  200  is used. However, as explained in the present embodiment, adjusting the waiting time to a shorter time can suppress the failure of the communication confirmation caused by the delay in Keep Alive signal or Keep Alive response. 
     Effects of Present Embodiment 
     According to the configuration of the present embodiment, the printer  10  determines the waiting time as the relatively-short first time of “1 minute” (S 22 ) in the case where the proxy server  200  is used (YES in S 20  of  FIG. 3 ), while it determines the waiting time as the relatively-long second time of “3 minutes” (S 24 ) in the case where the proxy server  200  is not used (NO in S 20 ). That is, the communication confirmation can suitably be executed based on whether the proxy server  200  is used or not. 
     Also in the case where the operation of changing the proxy setting information  44  is performed by the user (YES in S 10 ), the printer  10  adjusts the waiting time in accordance with the changed proxy setting information  44  (S 22  or S 24 ). For example, a comparative example is assumed here in which despite the proxy setting information  44  being changed, the waiting time according to the pre-change proxy setting information  44  is maintained. In this comparative example, the waiting time is maintained at a relatively long waiting time (e.g., “3 minutes”) even though the proxy setting information  44  has been changed to “ON”, as a result of which the communication confirmation may fail as in  FIG. 2 . Moreover, in this comparative example, the waiting time is maintained at a relatively short waiting time (e.g., “1 minute”) even though the proxy setting information  44  has been changed to “OFF”, as a result of which the number of times the communication confirmation is executed within a predetermined period (e.g., one day) may unnecessarily increase. Contrary to this, the present embodiment enables suitable execution of the communication confirmation even though the proxy setting information  44  is changed. 
     (Corresponding Relationships) 
     The printer  10  and the LAN I/F  12  are respectively examples of “communication device” and “communication interface”. The proxy server  200  is an example of “proxy server”. The SP server  100  is an example of “target server”. The HTTP session according to the XMPP over BOSH is an example of “session”. The Keep Alive signals and the Keep Alive responses are respectively examples of “confirmation signal” and “response signal”. The first time “1 minute” in S 22  and the second time “3 minutes” in S 24  are respectively examples of “first time” and “second time”. 
     S 42  to S 46  of  FIG. 3  are an example of “execute a communication confirmation”. Establishing the HTTP session in S 40  and executing the Negotiation in S 40  are respectively examples of “establish a session” and “adjust a waiting time”. 
     Second Embodiment 
     (Process by Printer;  FIG. 6 ) 
     The present embodiment is similar to the first embodiment except that a process of extending or shortening a waiting time is added in the process by the printer  10 . 
     S 50  and S 60  are similar to S 10  and S 20  of  FIG. 3 . The CPU  32  executes processes of S 62  and S 63  in a case of determining that the current proxy setting information  44  is “ON” (YES in S 60 ). S 62  is similar to S 22  of  FIG. 3 . In S 63 , the CPU  32  determines a first value (e.g., “4 minutes”) as an upper limit of an adoptable waiting time. Then, the CPU  32  stores the determined upper limit in the memory  34 . Here, the upper limit is a time shorter than the TCP timeout period. 
     On the other hand, the CPU  32  executes processes of S 64  and S 65  in a case of determining that the current proxy setting information  44  is “OFF” (NO in S 60 ). S 64  is similar to S 24  of  FIG. 3 . In S 65 , the CPU  32  determines a second value (e.g., “4.5 minutes”), which is larger than the first value, as an upper limit of an adoptable waiting time. Then, the CPU  32  stores the determined upper limit in the memory  34 . By setting the upper limit at a relatively long time in the case where the proxy setting information  44  is “OFF”, that is, in the case where the proxy server  200  is not used, the number of times the communication confirmation is executed within a predetermined period (e.g., one day) can be reduced as much as possible. In a variant, the CPU  32  may further determine a third value (e.g., “5 minutes”) as a timeout period in the case of determining that the current proxy setting information  44  is “ON” (YES in S 60 ), while it may further determine a fourth value (e.g., “6 minutes”), which is larger than the third value, as a timeout period in the case of determining that the current proxy setting information  44  is “OFF” (NO in S 60 ). 
     In a case of determining that the trigger of the process of  FIG. 6  is the printer  10  being turned on with the connection information  42  stored in the memory  34  (NO in S 50 ), the CPU  32  proceeds to S 70  and S 72 . S 70  is similar to S 30  of  FIG. 3 . In S 72 , the CPU  32  resets a new upper limit determined in S 92  (to be described later). Specifically, the CPU  32  determines the first value as the upper limit (see S 63 ) in the case where the proxy setting information  44  is “ON”, while it determines the second value as the upper limit (see S 65 ) in the case where the proxy setting information  44  is “OFF”. When any one of the processes of S 63 , S 65 , and S 72  is completed, a process of S 80  is executed. 
     S 80  to S 86  are similar to S 40  to S 46  of  FIG. 3 . In a case of determining that a Keep Alive response is not received from the SP server  100  (NO in S 86 ), the CPU  32  proceeds to S 90 . 
     In S 90 , the CPU  32  determines whether the determination of S 86  that a Keep Alive response is not received from the SP server  100  was made due to the timeout period having elapsed from the sending of the Keep Alive signal in S 82  without any signal being received from the SP server  100 , or not. In a case of determining that the determination was made due to the timeout period having elapsed (YES in S 90 ), the CPU  32  proceeds to S 92 . 
     In S 92 , the CPU  32  determines the current waiting time as a new upper limit instead of the upper limit in the memory  34 . Then, the CPU  32  stores the new upper limit in the memory  34 . If the current waiting time is adopted again as the waiting time despite the failure of the communication confirmation having been caused by the lapse of the timeout period, the communication confirmation is highly likely to fail again due to the lapse of the timeout period. By determining the waiting time as the new upper limit in the case where the failure of the communication confirmation is caused by the lapse of the timeout period, the communication confirmation can be suppressed from failing again due to the lapse of the timeout period. 
     Next, in S 94 , the CPU  32  shortens the waiting time. Specifically, the CPU  32  determines a value that is obtained by subtracting a predetermined time (e.g., “0.5 minutes”) from the current waiting time as a new waiting time instead of the current waiting time. When S 94  is completed, the CPU  32  returns to S 80  and attempts to establish an HTTP session again. 
     In a case of determining that the determination of S 86  that a Keep Alive response is not received from the SP server  100  was made due to a signal different from a Keep Alive response having been received from the SP server  100  before the timeout period elapses (NO in S 90 ), the CPU  32  skips the processes of S 92  and S 94  and returns to S 80 . The different signal as above is, for example, a signal indicating that the SP server  100  is incapable of sending a Keep Alive response due to maintenance and the like. Here, a comparative example is assumed in which the determination of S 90  is not executed and the waiting time is shortened regardless of the cause of the failure of the communication confirmation, for example. In a case where the waiting time is shortened due to the timeout period having elapsed, this comparative example can suppress the failure of the communication confirmation due to the lapse of the timeout period by shortening the waiting time, however, in a case where the waiting time is shortened due to a cause other than the lapse of the timeout period, the comparative example unnecessarily shortens the waiting time although the cause cannot be resolved. Contrary to this, by executing the determination of S 90 , the waiting time can be suppressed from being unnecessarily shortened. As a result, the number of times the communication confirmation is executed within a predetermined period (e.g., one day) can be suppressed from unnecessarily increasing. 
     In a case of determining that a Keep Alive response is received from the SP server  100  (YES in S 86 ), the CPU  32  proceeds to S 100 . In S 100 , the CPU  32  determines whether the Keep Alive response was received for the first time without the HTTP session established in S 80  being disconnected after it was established. In a case of determining that the Keep Alive response was received for the first time (YES in S 100 ), the CPU  32  proceeds to S 110 . 
     In  5110 , the CPU  32  extends the stored value. Specifically, the CPU  32  stores a value that is obtained by adding a predetermined time (e.g., “1 minute”) to the current stored value as a new stored value in the memory  34  instead of the current stored value. By extending the stored value, the CPU  32  can determine the extended stored value as the waiting time in the process of S 70  when the printer  10  is turned on again after the process of  FIG. 6  has terminated due to the printer  10  having been turned off. That is, the CPU  32  extends the waiting time that is to be used when the printer  10  is turned on the next time. The stored value is never extended exceeding the upper limit in the memory  34 . 
     In a case of determining that the Keep Alive response is received not for the first time (NO in S 100 ) or when S 110  is completed, the CPU  32  returns to S 82  and restarts the communication confirmation. In case of NO in S 100 , the waiting time of the SP server  100  is not extended. That is, the waiting time determined in the Negotiation of S 80  is maintained. 
     (Case B in which Proxy Server is Used;  FIGS. 7 and 8 ) 
     A specific Case B realized by the process of  FIG. 6  will be described with reference to  FIGS. 7 and 8 . In Case B, the proxy server is used. In the present case as well, processes similar to T 200  to T 210  of  FIG. 5  are executed. In the course of the processes, the printer  10  stores the waiting time “1 minute”, which is the first time, as a stored value. Then, in T 312 , the printer  10  determines the first value “4 minutes” as the upper limit (S 63  of  FIG. 6 ). Then, processes of T 320  to T 326 , which are similar to T 220  to T 226  of  FIG. 5 , are executed, as a result of which an HTTP session is established with the SP server  100  and the waiting time of the SP server  100  is determined as “1 minute”. 
     T 330 A to T 332 B are similar to T 230 A to T 232 B of  FIG. 5 . In T 334 , the printer  10  determines that the Keep Alive response was received for the first time without the HTTP session established in T 320  being disconnected after it was established (YES in S 100 ). In T 338 , the printer  10  extends the stored value from “1 minute” to “2 minutes” ( 5110 ). 
     T 340 A to T 342 B are similar to T 330 A to T 332 B of  FIG. 7 . That is, the waiting time of the SP server  100  is maintained at “1 minute”. In T 344 , the printer  10  determines that the Keep Alive response was received not for the first time (NO in  5100 ) and then repeats the communication confirmation. 
     In T 347 , the printer  10  accepts an operation of turning off the printer  10  from the user. As a result, the established HTTP session is disconnected. 
     Next, as shown in  FIG. 8 , the printer  10  accepts an operation of turning on the printer  10  from the user in T 348 . Then, in T 349 , the printer  10  determines the stored value of “2 minutes” as the waiting time (NO in S 50  and S 70  of  FIGS. 6 ). T 350  to T 356  are similar to T 320  to T 326  of  FIG. 7  except that the waiting time is “2 minutes”. That is, the SP server  100  determines the waiting time as “2 minutes”. 
     T 360 A to T 362 A are similar to T 330 A to T 332 A of  FIG. 7  except that the waiting time is “2 minutes”. However, in the present case, due to the waiting time having been extended to “2 minutes”, the timeout period of “5 minutes” elapses from the sending of the Keep Alive signal in T 360 A without a Keep Alive response being received from the SP server  100 . 
     In T 364 , the printer  10  determines that a Keep Alive response is not received from the SP server  100  due to the timeout period having elapsed (NO in S 86  and YES in S 90  of  FIG. 6 ). Then, in T 366 , the printer  10  determines the current waiting time of “2 minutes” as a new upper limit instead of the upper limit “4 minutes” in the memory  34  (S 92 ). 
     In T 368 , the printer  10  shortens the waiting time from “2 minutes” to “1.5 minutes”. T 370  to T 376  are similar to T 350  to T 356  except that the waiting time is “1.5 minutes”. T 380 A to T 382 B are similar to T 330 A to T 332 B of  FIG. 7  except that the waiting time is “1.5 minutes”. That is, the communication confirmation succeeds. 
     Effects of Present Embodiment 
     According to the present embodiment, the printer  10  extends the waiting time (S 110 ) in the case where the communication confirmation succeeds (YES in S 86  of  FIG. 6 ). Due to this, the number of times the communication confirmation is executed within a predetermined period (e.g., one day) can be reduced as compared to a comparative example in which the waiting time is not extended. Further, the printer  10  shortens the waiting time (S 94 ) in the case where the communication confirmation fails (NO in S 86 ). This can suppress the communication confirmation from failing again due to the lapse of the timeout period as compared to a comparative example in which the waiting time is not shortened. 
     Especially according to Case B, the printer  10  can determine the suitable waiting time of “1.5 minutes”, which is longer than the predetermined waiting time of “1 minutes”, considering that the communication confirmation is highly likely to fail due to the lapse of the timeout period with the waiting time of “2 minutes” (T 368  of  FIG. 8 ). As compared to the first embodiment in which the waiting time is maintained at the predetermined “1 minute” in the case where the proxy server  200  is used, the number of times the communication confirmation is executed within a predetermined period (e.g., one day) can be reduced. 
     (Corresponding Relationships) 
     The memory  34  of the printer  10  is an example of “memory”. The timeout period “ 5  minutes” is an example of “predetermined time”. The first value “4 minutes” in S 63  and the second value “4.5 minutes” in S 65  of  FIG. 6  are respectively examples of “first value” and “second value”. 
     (Variant 1) The “communication device” is not limited to the printer  10 , but may be a scanner, a multi-function device, or a terminal device such as a PC. 
     (Variant 2) In each of the above embodiments, the printer  10  adjusts the waiting time to one of the first time and the second time (S 22 , S 24  of  FIG. 3 ) in the case where the proxy setting information  44  is changed (YES in S 10  of  FIG. 3 ). Instead of this, the printer  10  may not adjust the waiting time in the case where the proxy setting information  44  is changed. In the present variant, “in a case where the state of the communication device is changed from the second state to the first state and the session is established again, the controller adjusts the waiting time to the first time” and “in a case where the state of the communication device is changed from the first state to the second state and the session is established again, the controller adjusts the waiting time to the second time” may be omitted. 
     (Variant 3) In the second embodiment as above, the printer  10  can execute both extending of the waiting time (S 110  of  FIG. 6 ) and shortening of the waiting time (S 94 ). Instead of this, the printer  10  may execute only one of extending of the waiting time and shortening of the waiting time. 
     (Variant 4) In the second embodiment as above, the determination of S 90  in  FIG. 6  may not be executed. Generally speaking, the waiting time may be shortened in both cases that a Keep Alive response is not received “due to a predetermined time having elapsed” and “due to a signal different from the response signal being received from the target server”. 
     (Variant 5) In the second embodiment as above, the upper limit of the waiting time in the case where the proxy setting information  44  is “OFF” is longer than the upper limit of the waiting time in the case where the proxy setting information  44  is “ON” (S 65  of  FIG. 6 ). Instead of this, the upper limit of the waiting time in the case where the proxy setting information  44  is “OFF” may be equal to the upper limit of the waiting time in the case where the proxy setting information  44  is “ON”. In this variant, the “second value” may be omitted. 
     (Variant 6) In the second embodiment as above, the process of S 92  of  FIG. 6  may not be executed. In the present variant, “store the waiting time that was used when the communication confirmation failed in a memory” may be omitted. 
     (Variant 7) The process of S 110  of  FIG. 6  (i.e., the process of extending the stored value) is an example of “extend the waiting time”. Instead of this, in the case of determining YES in S 100 , the printer  10  may determine a value that is obtained by adding a predetermined time (e.g., “1 minute”) to the current waiting time as a new waiting time instead of the current waiting time. That is, the printer  10  may extend the current waiting time. Further, the printer  10  may disconnect the HTTP session and establish an HTTP session again with the SP server  100  by using the connection information  42  in the memory  34 . Then, the printer  10  may execute, with the SP server  100 , Negotiation that includes instructing the SP server  100  to use the extended waiting time and may return to S 82 . In the present variant, extending the current waiting time is an example of “extend the waiting time”. 
     (Variant 8) In the above embodiments, the respective processes of  FIGS. 3 to 7  are realized by software (e.g., the program  40 ). Alternatively, one or more of the processes may be realized by hardware such as a logic circuit.